What it is
A service mesh is an infrastructure layer that handles service-to-service communication. A proxy runs next to every workload (classically as a sidecar container in each pod) and intercepts its inbound and outbound traffic. Together these proxies form the data plane. A control plane configures them: routes, endpoints, policies and the certificates that give each workload an identity. Istio (with Envoy) and Linkerd are the best-known implementations.
Why it exists
Once a system has dozens of services, every one of them needs the same networking features: timeouts, retries, load balancing, encryption and authentication between services, and metrics and traces. Built into each application, these get re-implemented per language and per library version, configured differently, and changed only by redeploying. A mesh moves them into infrastructure that is configured centrally and behaves the same for every service.
How it works
- Interception. The application sends a plain request to its destination; traffic is redirected (iptables rules or an eBPF/CNI equivalent) to the local proxy. Applications usually need no code change.
- Outbound proxy. The caller's proxy resolves the destination service to its current endpoints (pushed by the control plane), picks one with its balancing algorithm (round robin, least requests, consistent hash), applies timeouts and retries, and opens or reuses a connection.
- Mutual TLS. Between pods, the two proxies authenticate each other with certificates issued by the mesh's certificate authority, typically carrying a SPIFFE identity derived from the workload's service account. Authorization policies can then allow "Web may call Cart" by identity rather than IP. Connections are reused, so the handshake is per connection, not per request.
- Inbound proxy. The callee's proxy terminates TLS, enforces policy, records metrics and passes the request to the application over localhost.
- Control plane. It watches the cluster (services, endpoints, policy resources), computes each proxy's configuration and streams it (xDS for Envoy). It also rotates short-lived certificates. It is never on the request path, so a short outage freezes configuration but does not stop traffic.
- Failure handling. Proxies eject endpoints that fail (outlier detection on consecutive errors, plus Kubernetes readiness removing pods from endpoint lists) and can retry failed calls on another endpoint.
- Telemetry. Every proxy emits the same metrics per caller and callee and can create trace spans. To join spans into one trace, applications must forward trace context headers such as
traceparent.
When to use it
- Many services in several languages that need consistent retries, timeouts, encryption and telemetry.
- Zero-trust requirements: encrypt and authenticate all service-to-service traffic with workload identities and policies.
- Traffic management without redeploying: canary releases by weight, header-based routing, fault injection for testing.
When not to
- A handful of services in one language: a shared client library or framework middleware is cheaper and simpler.
- Latency-critical paths with very deep call graphs, where per-hop overhead adds up, unless a lighter data plane is used.
- Teams without capacity to operate and upgrade another distributed system; a misconfigured mesh can take down all traffic at once.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Sidecar mesh | Uniform features, no code changes, per-workload policy | A proxy per pod (CPU, memory), two extra hops per call, injection and upgrade complexity |
| Sidecarless (e.g. Istio ambient) | mTLS and L4 with a per-node proxy; L7 proxies only where needed | Newer model; shared per-node proxy; L7 features need extra waypoint proxies |
| Proxyless gRPC | No extra hop; clients take mesh config (xDS) directly | gRPC only; features limited to what the client library supports |
| Libraries instead of a mesh | Lowest overhead, full control | Per-language implementations that drift; changes need redeploys |
Alternatives
- Client libraries and middleware for retries, timeouts and metrics, with TLS from a platform or ingress.
- API gateway for north-south traffic (clients into the system); a mesh is mainly east-west (service to service).
- eBPF-based networking (e.g. Cilium) for L3/L4 policy, encryption and observability in the kernel, sometimes with an L7 proxy per node.
- Platform-managed networking in a managed container service that provides mTLS and service discovery.
Failure modes
- Bad configuration pushed everywhere: a wrong route or policy reaches every proxy within seconds. Roll out config changes gradually and validate them.
- Retry storms: retries at the mesh and in the application multiply load; use retry budgets and one retry layer.
- Control-plane outage: no new endpoints or certificates; a long one leads to stale routing and expiring certificates.
- Proxy resource limits: an under-provisioned sidecar becomes the bottleneck or is OOM-killed with its pod.
- Startup and shutdown ordering: the app starts sending before its proxy is ready, or the proxy exits before in-flight requests finish.
- Broken traces: applications that do not forward trace headers produce disconnected spans.
In production
Start with mTLS in permissive mode, then enforce it namespace by namespace. Set timeouts and retries per route, with retry budgets. Size proxies with resource requests and monitor their CPU and memory. Run the control plane highly available and upgrade it with canary revisions. Use the mesh's golden-signal metrics for SLOs per service, and make trace-context forwarding part of every service template. Measure the latency overhead on your own call graph rather than relying on published numbers.
Common misconceptions
- "The control plane routes the traffic." Only the proxies carry requests; the control plane configures them.
- "A mesh gives distributed tracing for free." It gives spans; applications still forward trace headers.
- "Mesh retries make every call reliable." They are safe only for idempotent calls and can amplify overload.
- "A mesh is required for microservices." It is one way to get consistent networking; libraries or platform features may be enough.
Interview angle
Bring up a mesh when the design has many services and needs consistent security and observability, and explain the split: sidecar proxies in the data plane, a control plane distributing configuration and certificates. Name the features (mTLS identities, retries, timeouts, outlier detection, telemetry), then the costs: per-hop latency, a proxy per pod, operational complexity. Mentioning that control-plane outages freeze configuration rather than stop traffic, and that sidecarless or proxyless modes exist, shows depth.
Model assumptions
Parts of this lesson are simulated and parts are scripted. Simulated by the queueing engine: users sending 150 requests per second to Web (5 ms of work), which calls two Cart pods (8 workers, 40 ms each). Without a mesh, a Kubernetes Service is modelled as an L4 balancer picking a pod at random. With a mesh, Web's sidecar is modelled as a balancer with 1 ms of processing and active health checks every 300 ms (two failures to eject), standing in for outlier detection, and each Cart pod's sidecar as a small server with 1 ms of work; in-pod hops take 0.5 ms and pod-to-pod hops 1 ms. The engine applies proxy processing on the request direction only. Scripted (hand-placed packets): control-plane configuration and certificate pushes, the TLS 1.3 handshake between sidecars, a sidecar retrying on the other pod, and telemetry export. The engine does not model TLS, configuration, proxy retries or telemetry. Numbers show behaviour and orders of magnitude, not benchmarks.