Building at scale · L2Service mesh and sidecars

Service mesh and sidecars

A service mesh moves mTLS, retries, traffic control and metrics out of your code and into proxies. Learn what that buys you, what it costs, and when to say no.

L2 SeniorBuilding at scale19 min read
Fact-checked by AI against cited sources · Human review pendingLast reviewed 9 Nov 2026 · How we check content
Section 1 of 8

What broke

On Friday 27 October 2017, at 14:10, Monzo deployed a change to a payments service. Current account payments started to fail. The team rolled the change back two minutes later. The errors did not stop 1.

Monzo used linkerd to route and load balance the calls between its several hundred services. Linkerd learned where each service ran from Kubernetes. At 14:18, engineers found that linkerd was sending traffic to IP addresses of processes that no longer existed. It had stopped getting updates 1.

At 14:26 they restarted all of the several hundred linkerd proxies. The new proxies could not start until the Kubernetes API servers were restarted too. By 15:13 every proxy was back, but no service got any traffic. Now the whole platform was down, including the app 1.

At 15:27 the logs showed the real blocker. Linkerd crashed with a NullPointerException while it read service discovery data. A new service, deployed the day before and then scaled to zero copies, triggered a bug between the linkerd and Kubernetes versions. Deleting that empty service fixed it at 15:31 1.

The first fault was a bug in Kubernetes and its etcd client after an etcd cluster upgrade a week or two earlier. Monzo called the restart of every proxy a poor decision that made the outage worse 1. The proxy layer touched every call. So when it broke, everything broke.

Section 2 of 8

The idea in simple words

In microservices, every call between services needs the same things. It needs a timeout, a retry rule, encryption, a check of who is calling, and metrics. You can write these in every service, in every language. Or you can move them into a proxy.

A service mesh is that proxy layer, plus a system that manages it. It has two parts 2:

  • The data plane. Proxies that carry every request between services. In Istio these are Envoy proxies, often deployed as sidecar proxies 2.
  • The control plane. A service that tells the proxies what to do: routes, endpoints, rules and certificates. In Istio this is istiod 2.

The app calls http://payments as if the network were simple. The proxies do the hard parts. Because the proxy is a separate process, it works with any language, and you can upgrade it without changing app code 9.

The key idea. A mesh does not remove network work. It moves that work out of your code into proxies that your team must now run. You trade code in many services for one more critical system.

Section 3 of 8

How it works

Step through one call from an orders service to a payments service. Use Next and Back, or the ← and → keys.

One call through a sidecar mesh: two proxies do the network workControl plane orders pod payments pod Orders Proxy Proxy Payments 1Orders makes a plain HTTP call.Its own proxy catches it. mTLS✓ caller is orders, callee is payments timeout 2 s · up to 2 retriesSet in mesh config, not in app code Metrics, traces Stale routes if the updates stop SeniorPath
  1. The orders service calls payments as if the network were simple. A proxy in the same pod catches the call. The app does not know it is there.
  2. The two proxies open a mutual TLS connection. Each one shows a certificate that names its workload. Then the payments proxy hands the request to the payments app.
  3. The client-side proxy applies the timeout and retry rules from the mesh config. You change them without a new build of the app.
  4. Both proxies report every request: count, errors, latency. They can also send trace spans. You get the same metrics for every service, in any language.
  5. The control plane sends each proxy its routes, the list of healthy endpoints, and signs its certificates. It is not on the request path. But if its updates stop, proxies keep routing on old data.
Step 1 of 5

mTLS and workload identity

In the TLS lesson you saw mutual TLS. A mesh makes it the default. Each workload gets a workload identity. In Istio, it comes from the workload's Kubernetes service account 3. An agent next to each proxy makes a private key and asks istiod to sign a certificate. It also renews that certificate before it expires 3. Nobody copies certificates by hand.

On each call, the client-side proxy starts the mTLS handshake. It checks that the server's certificate names a service account allowed to run the target service 3. The server-side proxy can then apply rules such as "only orders may call payments" 3.

To roll this out, start in permissive mode. It accepts both plain text and mTLS while you add proxies. Then switch to strict mode, which accepts only mTLS 3.

Timeouts, retries and traffic splitting

Mesh config sets timeouts and retries per service, with no app change. Check the defaults. In Istio, the HTTP timeout is off by default. Failed HTTP requests are retried twice before the error is returned 4.

That default meets your own code. Say your HTTP client tries each call 3 times. Each of those tries can become 3 attempts in the proxy. So one call can hit a failing service 9 times. This is retry amplification. Linkerd warns that services under constant retries can be taken down by them, not given time to recover 10.

Timeouts clash in the same way. Istio's docs give an example. The app has a 2 second timeout. The mesh has a 3 second timeout with one retry. The app gives up first, so the mesh settings have no effect 4. Mesh and app settings work on their own, and can conflict 4.

Retry only safe requests. Linkerd says retrying a request that changes state each time "can be disastrous" 10. Use idempotency keys for the rest.

The mesh can also split traffic by weight. Istio's example sends 75% of requests to version 1 and 25% to version 2, for a canary or an A/B test 4. You raise the weight in config, not with a new deploy.

The same proxies give you per-host limits and ejection of bad hosts. The circuit breakers lesson covers those.

Telemetry

Every proxy reports metrics for the traffic it carries 2. So you get request count, errors and latency for every service, in every language, from day one. Proxies can send trace spans too 11. But your app must still pass the trace headers from each incoming request to its outgoing calls 11. The distributed tracing lesson explains why.

What it costs

Resources. The Istio project tested version 1.24 at 1,000 requests per second with 1 KB payloads. One sidecar used about 0.20 vCPU and 60 MB of memory 5. Multiply that by your pods. For 400 pods, 60 MB each is 24 GB of memory just for proxies. Real numbers depend on your hardware and config 5.

Latency. In sidecar mode, each call passes through two extra proxies: one next to the caller and one next to the callee 3. Each hop adds a little time, and the TLS work adds more. Measure p99 latency before and after, on your own hardware.

Operational complexity. The mesh is now on the path of every call. Its upgrades, config pushes and bugs can break every service at once. That is what happened at Monzo 1. Someone must own it, upgrade it and debug it at 3 AM.

Confusing failures. An error may now come from a proxy, not from your app. Engineers must learn to read proxy logs and mesh config.

Sidecar or sidecar-less

Istio's own team listed the problems with sidecars. You must restart the app pod to add or upgrade a sidecar. Each sidecar is sized for its pod's worst case, so a lot of CPU and memory sits idle. And sidecars can break apps with non-standard HTTP code 7.

Ambient mode is Istio's answer. A ztunnel proxy runs once per node, not once per pod. It handles mTLS, L4 authorization and telemetry, and it does not read HTTP 6. For L7 features like HTTP routing and L7 authorization, you add waypoint proxies. These are Envoy proxies that run outside your app pods and scale on their own 6. Ambient mode became generally available in Istio 1.24, in November 2024 8.

In the same test, ztunnel used about 0.06 vCPU and 12 MB of memory per node. A waypoint used about 0.25 vCPU and 60 MB 5. Ambient and sidecar workloads can share one mesh, so you can move step by step 6.

Section 4 of 8

Trade-offs

OptionmTLS between servicesRetries and routingCost to runUse it when
Shared client libraryNo You build it yourself.Yes , in code. One version per language.Low. No new system.Few services, one or two languages.
Sidecar meshYes Automatic, with rotation. 3Yes Per service, in config. 4High. A proxy in every pod, and restarts to upgrade. 7Many services and languages, and a team to own the mesh.
Sidecar-less mesh (Istio ambient)Yes , from the per-node ztunnel. 6Only where you add waypoint proxies. 6Lower per pod. 5 Still a system to run.You mainly need mTLS and metrics, or sidecar cost is the blocker.
API gateway onlyNo Only at the edge.Yes , for outside traffic only.Medium. One layer at the edge.Your main need is clients outside, not service-to-service calls.

Simple rule: adopt a mesh for a need you can name, like mTLS everywhere or many languages. Do not adopt one because it is popular.

Section 5 of 8

At work: how a senior uses this

  • Ask "Which problem does the mesh solve that we cannot solve in a library?" If the answer is only retries, use a library.
  • Do not adopt a mesh when you have a few services, one language, no compliance need for mTLS, or nobody to own it.
  • Pick one layer for retries. If the mesh retries, turn them off in the app, or the other way round. Write that rule down.
  • Set a timeout in the mesh for every route. Make the app timeout a little longer than the mesh timeout × attempts.
  • Roll out mTLS in permissive mode first. Watch for plain-text traffic. Then go strict.
  • Treat a mesh upgrade like a database upgrade. Canary it on a few workloads, and have a rollback plan.
  • During an incident, do not restart every proxy at once. Monzo's restart turned a partial outage into a full one 1.
  • Alert on the control plane too: config push errors and stale endpoints, not only request errors.
Section 6 of 8

With AI

What to ask the agent

"Read our Istio VirtualService and DestinationRule files and our HTTP client config. For each route, list the app timeout, app retries, mesh timeout and mesh retries. Show the worst-case attempts per call."

"We have 30 services in Go and Java. List what we would gain and lose by adopting Istio ambient mode instead of sidecars. Cite the Istio docs for each point."

"Write a rollout plan to move these 5 namespaces to strict mTLS. Include how to find clients still sending plain text."

What to check yourself

  • Retry counts match the docs for your mesh version. Defaults change between versions.
  • Retries apply only to idempotent requests, such as GET, or requests with an idempotency key.
  • The agent did not set the mesh timeout longer than the app timeout.
  • Resource numbers come from your own load test, not from a blog post.
  • Config keys exist in your mesh version. Run the mesh's own config check before you apply anything.
Section 7 of 8

Check yourself

1. In a service mesh, which part sits on the path of every request?

Show answer

The data plane, meaning the proxies. The proxies carry all traffic between services. The control plane only configures them and gives them certificates.

2. Your code tries each call 3 times. The mesh keeps Istio's default retry policy. A downstream service is down. How many attempts can one call make?

Show answer

9 attempts. Istio retries twice by default, so each of your 3 tries becomes up to 3 attempts. 3 × 3 = 9.

3. Your app has a 2 second timeout. The mesh has a 3 second timeout with one retry. What happens when the callee hangs?

Show answer

The app gives up at 2 seconds, so the mesh retry never helps. Istio's docs use this exact case. The settings work independently, and the shorter app timeout wins.

4. What is the main reason Istio built ambient mode?

Show answer

Sidecars need a pod restart to install or upgrade, and must be sized for each pod's worst case. The ambient announcement names invasiveness and wasted resources. Waypoints in ambient mode still use Envoy.

5. You have six services in one language, a shared HTTP client library, and a two-person platform team. A teammate wants a mesh for retries. What is the best first answer?

Show answer

Put timeouts and retries in the shared library first, and revisit a mesh when you need mTLS or many languages. A mesh is one more system to run and upgrade. A shared library solves this need with far less to operate.

Your progress is saved only in this browser. Export it to keep it safe.

Was this clear?
Report a mistake (opens GitHub in a new tab)
Section 8 of 8

Go deeper

Show 11 sources and related lessons
  1. Monzo Community, “RESOLVED: Current account payments may fail - Major Outage (27/10/2017)”, post-incident write-up by Monzo's Head of Engineering (30 October 2017) (opens in a new tab)
    The full timeline of an outage where linkerd stopped getting routing updates, and a restart of every proxy made it worse.
  2. Istio documentation, “Architecture” (opens in a new tab)
    The data plane of Envoy proxies, the control plane (istiod), and the features each proxy has.
  3. Istio documentation, “Security” (opens in a new tab)
    Workload identity, how certificates are issued and rotated, the mutual TLS steps, and permissive and strict modes.
  4. Istio documentation, “Traffic Management” (opens in a new tab)
    Timeouts, retries, weighted routing for canaries, and how mesh and app retries can conflict.
  5. Istio documentation, “Performance and Scalability” (opens in a new tab)
    Measured CPU, memory and latency for sidecars, ztunnel and waypoints in Istio 1.24.
  6. Istio documentation, “Overview” (ambient mode) (opens in a new tab)
    How ambient mode splits the mesh into a per-node L4 proxy and optional L7 waypoint proxies.
  7. John Howard, Ethan J. Jackson, Yuval Kohavi, Idit Levine, Justin Pettit and Lin Sun, “Introducing Ambient Mesh”, Istio blog (7 September 2022) (opens in a new tab)
    The problems with sidecars that led Istio to build a mode without them.
  8. Lin Sun, “Fast, Secure, and Simple: Istio’s Ambient Mode Reaches General Availability in v1.24”, Istio blog (7 November 2024) (opens in a new tab)
    Ambient mode became generally available in Istio 1.24.
  9. Envoy documentation, “What is Envoy” (opens in a new tab)
    Why a proxy outside the app process works with any language and can be upgraded across a fleet.
  10. Linkerd documentation, “Retries and Timeouts” (opens in a new tab)
    Why mesh retries should be limited to idempotent requests, and how they can take services down.
  11. Istio documentation, “Overview” (distributed tracing) (opens in a new tab)
    Proxies send spans, but your app must pass the trace headers along.

Real incident: Monzo, 27 Oct 2017: Monzo outage: stale proxy routes, then a restart of every proxy

Related: Load balancing · TLS and secure connections · Circuit breakers, bulkheads and fallbacks · Backoff, jitter and retry budgets · Distributed tracing in practice · DNS and service discovery · Safe deploys and config changes · API gateways and edge concerns · Sidecar, ambassador and other service patterns (coming soon)

Term

See full entry

Jump to a section

  1. 1What broke
  2. 2The idea in simple words
  3. 3How it works
  4. 4Trade-offs
  5. 5At work
  6. 6With AI
  7. 7Check yourself
  8. 8Go deeper