What is a Service Mesh and what problems does it solve?

Topic: microservices, Infrastructure. Level: Hard.

Answer

A service mesh (Istio, Linkerd) is an infrastructure layer that handles service-to-service communication via **sidecar proxies** deployed next to each service. It moves cross-cutting concerns — mTLS, retries, timeouts, circuit breaking, load balancing, traffic shifting (canary), and telemetry — out of application code and into the platform, configured declaratively. The **data plane** (sidecars) carries traffic; the **control plane** configures them. Benefit: consistent, language-agnostic resilience/security/observability without touching app code; cost: added complexity and per-hop latency. ```yaml # Istio: enforce mTLS + retries + timeout WITHOUT changing service code apiVersion: networking.istio.io/v1beta1 kind: VirtualService spec: hosts: [ payment ] http: - route: [ { destination: { host: payment } } ] timeout: 3s retries: { attempts: 3, perTryTimeout: 1s, retryOn: 5xx } ```