A helper next to your service that makes the outside calls for it: retries, routing, monitoring.
The ambassador pattern puts a small helper program next to your app that makes the app's outgoing calls for it. The app talks to localhost, and the ambassador talks to the world.
Every app that calls another service needs the same networking skills: wait a sensible time, try again when it fails, stop calling a broken service, find the right server, and use an encrypted connection. If this code is written inside every app, you get a different version in each language, and every change means a new build of every app.
An ambassador takes this job away from the app. It is a helper process or container, deployed beside each app instance (for example in the same Kubernetes pod). The app sends a plain request to localhost. The ambassador adds the retries, timeouts and security, finds the right backend, sends the request, and hands the answer back.
The name fits: an ambassador represents a country in a foreign land. Your app stays at home and deals with the ambassador next door, and the ambassador deals with the outside world. It also helps with old apps you cannot change: you only point their address at the local helper.
| Job | What it does | Why the app does not have to |
|---|---|---|
| Retries and backoff | Tries again after a growing wait, up to a limit | No retry loop in each language |
| Timeouts | Cuts off a call that takes too long | One setting for every app |
| Circuit breaking | Stops calling a service that keeps failing | No breaker library per app |
| Routing and discovery | Finds the right backend or shard | The app only knows localhost |
| TLS and authentication | Encrypts the call and adds credentials | Certificates stay out of the app |
| Observability | Logs, metrics and traces for each call | Same data from every app |
| Question | Library in the app | Ambassador |
|---|---|---|
| Language support | One build per language | Any language |
| Extra hop | None | A small local hop |
| Resource use | Part of the app | Extra memory and CPU per instance |
| Change a policy | Edit code, build and redeploy every app | Change the helper config or image |
| Works with apps you cannot change | No | Yes, if the address can be changed |
Success rate = 1 minus the failure chance to the power of (retries + 1), assuming every try fails independently with the same chance. Real failures often come in bursts, so retries help less than this, and they add load to a backend that is already struggling (this is why you also need backoff and a circuit breaker). The hop time is a made-up number.
| Term | Meaning in easy words |
|---|---|
| Ambassador | A helper beside an app that makes the app's outgoing calls for it |
| Sidecar | Any helper container deployed beside the main app |
| Outbound traffic | Calls that leave the app to reach other services |
| Local proxy | A proxy running on the same machine or pod as the client |
| localhost | The address a program uses to talk to another program on the same machine |
| Retry | Trying a failed call again |
| Backoff | Waiting longer between each retry |
| Circuit breaker | A switch that stops calls to a failing service for a while |
| Service discovery | Finding the current addresses of a service |
| mTLS | Mutual TLS: both sides prove who they are and the traffic is encrypted |
| Fleet-wide change | A setting change that applies to every instance at once |
| Choice | We gain | We lose |
|---|---|---|
| Ambassador instead of library | Language freedom and central changes | Memory, CPU and a local hop per instance |
| Policy in shared config | One change reaches every app | A mistake reaches every app, too |
| Retries in the ambassador | Simple apps, same behaviour everywhere | Less control for special calls in the app |
| Retries in the app | Full control per call | Different code and bugs in each language |
| Ambassador per instance | Failure stays local to one instance | Many copies to run and update |
| Shared node-level proxy | Fewer copies, less memory | A bigger blast radius if it fails |