Bookmarks

Service mesh

A communication layer between microservices: dedicated proxies next to each service take over routing, encryption and retries, so the application code does not have to deal with them.

Also: mesh, service grid

checked 8 Nov

All terms

In a large application made of microservices, every call to a neighbour can fail, slow down or be intercepted. A service mesh is an infrastructure layer that takes these tasks on itself: a proxy runs next to each service, and a shared control layer sets the rules for all the proxies. The application code stays unchanged.

How it is structured

The proxy next to a service is called a sidecar: sidecars are deployed together with the application, and all traffic between the services goes through them. The set of sidecar proxies is the data plane, and the services that hand them configuration and certificates are the control plane. Istio can also work without sidecars: in ambient mode a shared proxy sits on every node of the cluster rather than in every pod.

PlaneWhat it does
Datathe sidecar proxies (Envoy in Istio, Linkerd’s own proxy written in Rust) intercept all incoming and outgoing traffic of a pod and apply the rules
Controlkeeps track of the services and hands the proxies configuration and certificates

What it takes over

  • mutual authentication and encryption of traffic between services over mTLS — certificates are issued and renewed automatically;
  • retries, timeouts and circuit breaking on failures;
  • routing by version: for example, sending 5% of traffic to a new version for a canary release;
  • metrics, logs and tracing of every call — the proxies collect them and send them to monitoring systems;
  • access control: which service may call which, decided by workload identity rather than by IP address.

An example with Istio

yamlA rule for the payments service: mutual TLS and connection settings
apiVersion: networking.istio.io/v1kind: DestinationRulemetadata:  name: paymentsspec:  host: payments  trafficPolicy:    tls:      mode: ISTIO_MUTUAL  # mTLS between services    connectionPool:      http:        h2UpgradePolicy: UPGRADE

After Istio is installed into a Kubernetes cluster, a call between pods passes through two Envoy sidecar proxies — on the sender and on the receiver. The proxies enforce mTLS, collect telemetry and decide afresh each time which pod to hand the request to. Istiod acts as the certificate authority and issues the certificates, so encryption is switched on without any manual key distribution.

When a mesh is needed and when it is not

A mesh pays off most when there are many services and different teams are losing track of how they interact: regulatory requirements for encryption inside the perimeter appear, and unified telemetry is needed. For a dozen services owned by a single team it is cheaper to make do with libraries and Kubernetes settings — a proxy in every pod consumes memory and adds latency to every call.

Sources

the term is written from these pages

Verified 8 Nov

Not to be confused with

what it is mixed up with and how it differs

  • API gateway

    An API gateway is the single entry point for clients from outside; the mesh connects the services to each other inside the cluster.

  • ESBenterprise service bus

    An ESB is a centralised hub through which messages flow and where the integration business logic lives; a mesh has no such hub.

In depth in the references

where the topic is covered in detail