Circuit Breaker Placement: Client Side, Service Mesh, or Gateway
Client Side Placement
Circuit breakers embedded in the calling service code. Each service instance maintains its own breaker state and failure counts. Advantages: no additional infrastructure, fine grained control per caller, works with any protocol. Disadvantages: inconsistent state across instances (one instance may have open breaker while others are closed), requires library support in each language, configuration scattered across services.
Service Mesh Placement
Circuit breakers in sidecar proxies (the separate container that handles all network traffic for a service). Each service pod has a proxy that handles circuit breaking transparently. Advantages: language agnostic, consistent behavior across services, centralized configuration, no code changes needed. Disadvantages: adds 1-2ms latency per hop, operational complexity of managing the mesh, still per instance state unless using mesh control plane.
Gateway Placement
Single circuit breaker at the API gateway protecting all callers. One breaker instance means consistent state: if the downstream service fails, all callers see the open state simultaneously. Advantages: single point of configuration, consistent protection, global view of downstream health. Disadvantages: single point of failure, coarse grained (cannot differentiate callers), may not protect internal service to service calls.
Combining Placements
Production systems often layer circuit breakers. Gateway breakers protect against external traffic spikes. Service mesh breakers handle internal service communication. Client side breakers add application specific logic like custom fallbacks. The key is avoiding conflicting thresholds where one breaker trips before another can help.