Stackbook Logo
distribution-communicationestablished · medium operational burden

Ambassador

Also known as: ambassador-proxy, outbound-proxy

Intent

Place a helper process next to a client that handles outbound network concerns such as retries, routing, monitoring and security on its behalf.

Problem

Clients calling remote or legacy services each need connection handling, retries, TLS, circuit breaking and metrics. Embedding this in every client duplicates code and cannot be applied to software you cannot modify.

Forces

  • •Outbound call logic is repeated across clients
  • •Some clients cannot be changed or recompiled
  • •Remote endpoints require discovery, auth and throttling
  • •Local calls should stay simple and fast

Solution

Overview

The ambassador pattern represents a client to the outside world. The application talks to a local proxy; the proxy deals with the messy realities of the network. It is the egress-focused sibling of the sidecar.

How it works

The proxy listens on a local port. The client connects to it with plain protocol and no resilience logic. The ambassador resolves the destination, picks a healthy instance, opens a pooled TLS connection, attaches credentials, enforces a timeout and retries safe requests.

client --> localhost:6379 --> ambassador --TLS--> redis shard 2
                                |
                                +-- metrics, logs, retries, auth

A classic case is a legacy application using a single database address while the ambassador routes keys to shards or reads to replicas.

Pitfalls

  • Blind retries. Only retry idempotent operations and cap attempts with a budget, otherwise an outage is amplified.
  • Hiding failures. The client should still receive clear errors and deadlines propagated through the proxy.
  • Treating the proxy as stateless when it caches discovery results; define refresh and expiry.
  • Port and lifecycle coupling. Start the ambassador before the client and stop it after.
  • Duplicating policy in both the client library and the ambassador, causing retry storms through stacked layers.
  • No metrics from the proxy itself, leaving it a blind spot.

Key takeaways

  • An ambassador is an outbound proxy next to the client.
  • Use it when you cannot or should not modify the client.
  • Centralise retry, auth and routing policy there, once.
  • Avoid stacking retries across layers.
  • Monitor and version the proxy like any production component.

✓ When to Use

  • •Legacy or third-party clients needing resilience features
  • •Uniform outbound policy across languages
  • •Offloading connection pooling and sharding logic from clients

✗ When Not to Use

  • •Inbound traffic concerns, where a gateway fits better
  • •Clients already using a well-maintained resilience library
  • •Latency-critical calls where the extra local hop matters

Pros

  • +Adds resilience and security without client changes
  • +Centralised egress policy and telemetry
  • +Simplifies client code to a localhost call

Cons

  • −Extra process per client to run and patch
  • −Added local hop and failure point
  • −Debugging spans two layers

Cost Profile

Infrastructure

Low - lightweight proxy per host or pod

Operational

Medium - policy distribution and upgrades

Cognitive

Low - client sees a simple endpoint

Failure Modes

  • Ambassador retries multiply load on an already failing service

  • Misrouted traffic because stale discovery data

  • Client treats localhost as reliable and has no fallback when the proxy dies

Real-World Examples

Alternatives

  • sidecar

Related Patterns

  • sidecar
  • circuit-breaker
  • retry-with-backoff
  • service-discovery

Competency Domains

distribution communicationreliability ops