Back to the map

Module 12 · Microservices patterns · Lesson 4 of 8

Sidecar

A helper process deployed next to each service instance that provides networking, security, observability or configuration without changing the application. Why co-location rather than a library, what typically rides in a sidecar.

CoreNice-to-knowMid 10 minPro Updated Nov 2026

Why it matters

Every service needs the same things: TLS to its peers, retries and timeouts, metrics, log shipping, secrets, configuration refresh. Implementing them as a library in every language the organisation uses means five implementations that drift and a coordinated upgrade whenever one changes. The sidecar pattern moves those concerns into a separate process that runs beside each instance, so the application stays focused and the platform team owns the shared behaviour. It is the mechanism underneath service meshes and much of modern platform engineering.

The idea

A sidecar is a secondary process deployed in the same unit as the application (the same Kubernetes pod, the same VM) sharing its network namespace and lifecycle. The application talks to the sidecar over localhost, or the sidecar transparently intercepts the application's traffic, and the sidecar handles the cross-cutting concern. Because it is a separate process, it can be written once in one language, upgraded independently, and attached to any service regardless of the service's language or framework.

podappbusiness logicsidecarEnvoylocalhostmTLS, retriesinboundother servicesmetrics · traces · logs · certificates · config, all from the sidecar
The application process and its sidecar share a pod and network namespace. Traffic in and out passes through the sidecar, which adds TLS, retries, metrics and tracing without application changes.

What rides in a sidecar

ConcernSidecar roleExample
Service-to-service networkingDiscovery, load balancing, retries, timeouts, circuit breaking on behalf of the appEnvoy, Linkerd proxy
SecurityMutual TLS with automatic certificate rotation; authorization policy between servicesIstio, Consul Connect, SPIFFE identities
ObservabilityUniform metrics, access logs and trace spans for every request without app codeMesh telemetry, OpenTelemetry collector sidecars
Log and metric shippingTail the app's logs and forward themFluent Bit, Vector
Configuration and secretsFetch and refresh config and secrets, present them to the app as files or a local endpointVault agent, config reloaders
Protocol adaptationExpose a legacy or foreign protocol as something the app understandsAmbassador and adapter variants

The ambassador variant is a sidecar that proxies outbound calls to external systems (handling auth, retries and rate limits for a third-party API); the adapter variant normalises the application's output (metrics, logs) into a standard format.

Why not a library

A library is in-process and faster, and for a single-language organisation with a mature shared library it is a fine choice. Sidecars win when the organisation is polyglot, when the platform team must upgrade behaviour without waiting for every service to rebuild, when the concern involves network interception (mTLS) that is awkward in-process, and when uniform telemetry across services matters more than a millisecond.

Costs

Each sidecar consumes memory and CPU (tens to hundreds of megabytes and a fraction of a core per instance), which multiplied across thousands of pods is a real bill. It adds a hop on localhost, typically well under a millisecond but visible at the tail. It complicates the pod lifecycle: the sidecar must start before the app and stop after it, which orchestrators now support natively. Debugging gains a layer. Sidecarless meshes (Istio ambient mode, eBPF-based approaches) move the proxy to a per-node agent to reclaim those resources, trading per-pod isolation for efficiency.

Where it leads

Deploying the same sidecar beside every service and controlling them from a central control plane is a service mesh, the last lesson of this module. The sidecar is the data plane; the control plane distributes configuration, certificates and policy. Understanding the sidecar as a pattern first makes the mesh an obvious consequence rather than a mystery.

Sidecar · Backplane