Day 12: Linkerd – retries, timeouts, mTLS
Goal: Bring
kurzinto the service mesh, measure what the proxy costs, prove mTLS between pods, and then smuggle in two broken copies ofkurz– one that only returns errors and one that takes two seconds. How do the mesh and the gateway deal with them? · Duration: approx. 110 min · Prerequisite: Day 11
Briefing
- Until yesterday, only one component judged traffic: Envoy at the
entrance. What happens between the pods –
kurzto Valkey, PostgreSQL, NATS, another service tokurz– ran unprotected and unencrypted. Linkerd puts a proxy next to every app that takes over exactly this traffic. - The mesh brings three things without
kurzchanging a single line: mTLS with one identity per ServiceAccount, load balancing by measured latency (EWMA) and, on request, retries and timeouts on the caller’s side. - The mesh only works between pods that both have a proxy. Envoy at
the gateway is not part of it – its retries and timeouts still come from
the
BackendTrafficPolicyof Day 4 and 11.
| Term | Meaning |
|---|---|
| Proxy | linkerd-proxy, as a native sidecar (init container with
restartPolicy: Always) |
| Identity | certificate per ServiceAccount,
e.g. default.kurz.serviceaccount.identity.linkerd.cluster.local |
| EWMA | “exponentially weighted moving average”: the proxy prefers the endpoint with the lowest latency |
| Retry, timeout | done by the proxy of the caller, configured on an HTTPRoute with the Service as parent resource |
| Failure accrual | circuit breaking in the mesh: after n consecutive failures, an endpoint is blocked for a while |
Linkerd is the subject of a course of its own (“Linkerd hands-on”).
Today is only about the system design question: what does
kurz gain, and what does it cost?
Drill 1: Installing Linkerd
The same version and the same path as in the Linkerd course: edge
release edge-26.11.2, the CLI with a verified checksum.
# on s1
mkdir -p ~/sdk/tag12 && cd ~/sdk/tag12
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
# download the CLI, check the checksum against the list on GitHub, install
ARCH=$(dpkg --print-architecture); V=edge-26.11.2
curl -fsSLO https://github.com/linkerd/linkerd2/releases/download/$V/linkerd2-cli-$V-linux-$ARCH
S=$(sha256sum linkerd2-cli-$V-linux-$ARCH | cut -d' ' -f1)
curl -fsSL https://api.github.com/repos/linkerd/linkerd2/releases/tags/$V | grep -q "sha256:$S" && echo "Prüfsumme ok"
sudo install -m 0755 linkerd2-cli-$V-linux-$ARCH /usr/local/bin/linkerd
# does the cluster fit? (k3s ships the Gateway API CRDs, Day 3)
linkerd check --pre | tail -1
# CRDs, then the control plane
linkerd install --crds > crds.yaml && kubectl apply -f crds.yaml >/dev/null
linkerd install > control-plane.yaml && kubectl apply -f control-plane.yaml >/dev/null
linkerd check | tail -1
kubectl -n linkerd get pods -o custom-columns=NAME:.metadata.name,READY:.status.containerStatuses[0].ready,NODE:.spec.nodeNameExpected:
Prüfsumme ok
Status check results are √
Status check results are √
NAME READY NODE
linkerd-destination-848cc67656-bgqmc true s1
linkerd-identity-779c547d74-94n7q true s1
linkerd-proxy-injector-fd5c4f46c-f5g2n true s1
For this lab, linkerd install generates its own
self-signed trust certificate. In production, it belongs in a CA of your
own (Linkerd course, Day 5).
Save your progress? Sign up for free
Drill 2: kurz into the mesh – and what it costs
One annotation in the pod template is enough. The injector adds the proxy on the next rollout.
# on s1
# manifest from Day 9 plus an annotation in the pod template
python3 - <<'EOF'
s = open("../tag09/kurz.yaml").read()
alt = " metadata:\n labels:\n app: kurz\n"
neu = alt + " annotations:\n linkerd.io/inject: enabled\n"
open("kurz.yaml", "w").write(s.replace(alt, neu, 1))
EOF
diff ../tag09/kurz.yaml kurz.yaml
kubectl apply -f kurz.yaml && kubectl -n kurz rollout status deploy kurz
# the proxy is listed among the init containers (native sidecar)
kubectl -n kurz get pods -l app=kurz -o jsonpath='{range .items[*]}{.metadata.name} init={.status.initContainerStatuses[*].name} ready={.status.initContainerStatuses[*].ready}{"\n"}{end}'Expected:
23a24,25
> annotations:
> linkerd.io/inject: enabled
deployment "kurz" successfully rolled out
kurz-85866bf89d-64sbh init=linkerd-init linkerd-proxy ready=true true
kurz-85866bf89d-l77w9 init=linkerd-init linkerd-proxy ready=true true
Now the price. The same load as on Day 11 (1000 per second through
the gateway), alternating without (ohne) and with
(mit) the proxy, twice:
# on s1
cp ../tag11/codes.txt ../tag11/status.js .
for v in ohne mit ohne mit; do
if [ $v = mit ]; then kubectl apply -f kurz.yaml >/dev/null; else kubectl apply -f ../tag09/kurz.yaml >/dev/null; fi
kubectl -n kurz rollout status deploy kurz >/dev/null; sleep 25
echo "== $v Linkerd"
k6 run -q -e ZIEL=http://172.16.0.126 -e RATE=1000 -e DAUER=40s status.js 2>&1 \
| grep -A1 -E '\{status:(302|503)\}' | sed 's/ */ /g' | grep -v '^--' | paste - - | grep -v 'count=0\|p(95)=0s'
kubectl top pods -n kurz -l app=kurz --containers | tail -n +2 | awk '{print " ", $2, $3}'
doneExpected (abridged):
== ohne Linkerd
http_req_duration{status:302} ✓ 'p(95)>=0' p(95)=64.41ms
http_reqs{status:302} ✓ 'count>=0' count=39872
kurz 464m
kurz 601m
== mit Linkerd
http_req_duration{status:302} ✓ 'p(95)>=0' p(95)=107.79ms
http_reqs{status:302} ✓ 'count>=0' count=39845
kurz 374m
kurz 444m
linkerd-proxy 369m
linkerd-proxy 422m
== ohne Linkerd
http_req_duration{status:302} ✓ 'p(95)>=0' p(95)=70.84ms
== mit Linkerd
http_req_duration{status:302} ✓ 'p(95)>=0' p(95)=158.03ms
http_req_duration{status:503} ✓ 'p(95)>=0' p(95)=11.81ms
http_reqs{status:302} ✓ 'count>=0' count=39598
http_reqs{status:503} ✓ 'count>=0' count=119
The proxy uses almost as much CPU as kurz itself, and
p95 rises from 64–71 to 108–158 ms. Every redirect passes through it
several times: the request from Envoy, the query to Valkey, the message
to NATS. The 119 × 503 in the second run come from the
circuit breaker of Day 11: with the proxy, requests take longer, so more
are in flight at the same time, and the limit of 100 parallel requests
per Envoy kicks in more often. A mesh is not free, and on a tight lab
you see it clearly.
Save your progress? Sign up for free
Drill 3: Who talks encrypted?
mTLS only exists between two proxies. Envoy at the gateway has none.
For the comparison, you need a second caller in the mesh: a pod with k6
that talks to kurz directly via the Service.
# on s1
# load script for the pod: additionally counts 200 and 504
sed -e 's#"http_reqs{status:503}": \["count>=0"\],#"http_reqs{status:503}": ["count>=0"], "http_reqs{status:200}": ["count>=0"], "http_reqs{status:504}": ["count>=0"], "http_reqs{status:0}": ["count>=0"],#' \
-e 's#"http_req_duration{status:503}": \["p(95)>=0"\],#"http_req_duration{status:503}": ["p(95)>=0"], "http_req_duration{status:200}": ["p(95)>=0"], "http_req_duration{status:504}": ["p(95)>=0"], "http_req_duration": ["p(95)>=0"],#' \
status.js > status2.js
kubectl -n kurz create configmap last-skripte --from-file=status2.js --from-file=codes.txt
# load generator in the mesh
cat > last.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: last
namespace: kurz
spec:
replicas: 1
selector:
matchLabels:
app: last
template:
metadata:
labels:
app: last
annotations:
linkerd.io/inject: enabled
spec:
containers:
- name: k6
image: grafana/k6:2.4.0
command: ["sleep", "infinity"]
workingDir: /skripte
volumeMounts:
- name: skripte
mountPath: /skripte
resources:
requests:
cpu: 200m
memory: 128Mi
volumes:
- name: skripte
configMap:
name: last-skripte
EOF
kubectl apply -f last.yaml && kubectl -n kurz rollout status deploy last
# function mesh: load from the pod last directly onto the Service kurz
mesh() { kubectl -n kurz exec deploy/last -c k6 -- k6 run -q -e ZIEL=http://kurz.kurz.svc.cluster.local "$@" status2.js; }
# some load from the mesh and through the gateway, then the view of kurz's proxy
mesh -e RATE=20 -e DAUER=5s >/dev/null 2>&1
k6 run -q -e ZIEL=http://172.16.0.126 -e RATE=20 -e DAUER=5s status.js >/dev/null 2>&1
P=$(kubectl -n kurz get pods -l app=kurz -o name | head -1)
linkerd diagnostics proxy-metrics -n kurz $P | grep '^inbound_http_authz_allow_total' \
| grep -o -E 'tls="[^"]*",(no_tls_reason|client_id)="[^"]*"|[0-9]+$' | paste - - \
| awk '{s[$1]+=$2} END {for (k in s) print s[k], k}' | sort -rnExpected (the counters run since the pod started):
31234 tls="no_identity",no_tls_reason="no_tls_from_remote"
19278 tls="true",client_id="default.kurz.serviceaccount.identity.linkerd.cluster.local"
Requests from the mesh arrive encrypted and with an identity –
default is the ServiceAccount that last runs
under. Everything from Envoy arrives unencrypted
(no_tls_from_remote). If you also want to encrypt the path
from the gateway, bring Envoy into the mesh or let Envoy itself speak
TLS to the backend.
Save your progress? Sign up for free
Drill 4: A broken copy
A third “copy” of kurz that answers every request with
503 – this is what a pod looks like after a bad rollout
whose readiness probe notices nothing. It carries the label
app=kurz and thus lands behind the Service. KEDA is paused
for the time being so that the foreign pods do not distort the CPU
measurement.
# on s1
kubectl -n kurz annotate scaledobject kurz autoscaling.keda.sh/paused-replicas=2 --overwrite
cat > kurz-kaputt.yaml <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
name: kurz-kaputt
namespace: kurz
data:
default.conf: |
server {
listen 8080;
location / { return 503 "kaputt\n"; }
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kurz-kaputt
namespace: kurz
spec:
replicas: 1
selector:
matchLabels:
app: kurz
variante: kaputt
template:
metadata:
labels:
app: kurz
variante: kaputt
annotations:
linkerd.io/inject: enabled
spec:
containers:
- name: nginx
image: nginx:1.30.8-alpine
ports:
- name: http
containerPort: 8080
volumeMounts:
- name: conf
mountPath: /etc/nginx/conf.d
volumes:
- name: conf
configMap:
name: kurz-kaputt
EOF
kubectl apply -f kurz-kaputt.yaml && kubectl -n kurz rollout status deploy kurz-kaputt
# three endpoints behind the Service
kubectl -n kurz get endpointslices -l kubernetes.io/service-name=kurz -o jsonpath='{range .items[*].endpoints[*]}{.targetRef.name} {end}{"\n"}'
# function zaehle: only the status lines of a k6 output
zaehle() { grep -A1 -E 'http_reqs\{status:(200|302|503|504)\}|^ *http_req_duration$' | sed 's/ */ /g' | grep -v '^--' | paste - - | grep -v 'count=0\|p(95)=0s'; }
echo "== im Mesh"; mesh -e RATE=200 -e DAUER=30s 2>&1 | zaehle
echo "== über das Gateway"; k6 run -q -e ZIEL=http://172.16.0.126 -e RATE=200 -e DAUER=30s status2.js 2>&1 | zaehleExpected:
kurz-77c9dc76b4-dptt7 kurz-77c9dc76b4-4zv9k kurz-kaputt-6785b6f778-9cxts
== im Mesh
http_reqs{status:302} ✓ 'count>=0' count=2429
http_reqs{status:503} ✓ 'count>=0' count=3572
== über das Gateway
http_reqs{status:302} ✓ 'count>=0' count=5991
http_reqs{status:503} ✓ 'count>=0' count=10
Two surprises. In the mesh (im Mesh), 60
% fail – not a third. The broken pod answers fastest (a
503 costs nothing), and the proxy prefers the fastest
endpoint. Fast errors attract traffic. Through the gateway
(über das Gateway), on the other hand, only 10 errors: the
passive health check from Day 4 (consecutive5XxErrors: 5)
took the pod out of traffic after five errors.
Save your progress? Sign up for free
Drill 5: Retries and failure accrual in the mesh
You configure retries on an HTTPRoute whose parent resource is the
Service. The rule for / is important: once a route is
attached to the Service, the proxy itself answers every path that no
rule matches with 404 (Linkerd course, Day 7).
# on s1
cat > route-retry.yaml <<'EOF'
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: kurz-mesh
namespace: kurz
annotations:
retry.linkerd.io/http: 5xx
retry.linkerd.io/limit: "2"
spec:
parentRefs:
- group: core
kind: Service
name: kurz
port: 80
rules:
- matches:
- path:
type: PathPrefix
value: /
EOF
kubectl apply -f route-retry.yaml
# only Linkerd accepts the route; Envoy Gateway ignores routes without a Gateway as parent
kubectl -n kurz get httproute kurz-mesh -o jsonpath='{range .status.parents[*]}{.controllerName}: {range .conditions[*]}{.type}={.status} {end}{"\n"}{end}'
# function retries: retries the proxy of last has made so far
L=$(kubectl -n kurz get pods -l app=last -o name)
retries() { linkerd diagnostics proxy-metrics -n kurz $L | grep '^outbound_http_route_retry_requests_total' | awk '{s+=$NF} END {print s+0}'; }
A=$(retries); mesh -e RATE=200 -e DAUER=30s 2>&1 | zaehle; echo "Retries: $(( $(retries) - A ))"Expected:
httproute.gateway.networking.k8s.io/kurz-mesh created
linkerd.io/policy-controller: Accepted=True ResolvedRefs=True
http_req_duration ✓ 'p(95)>=0' p(95)=52.29ms
http_reqs{status:302} ✓ 'count>=0' count=6000
http_reqs{status:503} ✓ 'count>=0' count=1
Retries: 417
One error in 6001 requests, but 417 additional requests to
kurz – and the broken pod keeps getting traffic. It would
be better not to ask it at all for a while: failure
accrual, the circuit breaking of the mesh, on the Service.
# on s1
# after 3 consecutive failures an endpoint is blocked (the block time grows with further failures)
kubectl -n kurz annotate svc kurz balancer.linkerd.io/failure-accrual=consecutive \
balancer.linkerd.io/failure-accrual-consecutive-max-failures=3 --overwrite
sleep 10
for i in 1 2; do A=$(retries); mesh -e RATE=200 -e DAUER=30s 2>&1 | zaehle; echo "Retries: $(( $(retries) - A ))"; doneExpected:
service/kurz annotated
http_req_duration ✓ 'p(95)>=0' p(95)=24.63ms
http_reqs{status:302} ✓ 'count>=0' count=6001
Retries: 9
http_req_duration ✓ 'p(95)>=0' p(95)=30.46ms
http_reqs{status:302} ✓ 'count>=0' count=6000
Retries: 1
Retries repair individual errors; failure accrual takes a permanently broken endpoint out of the game. Together: no errors, hardly any extra load, p95 halved.
Save your progress? Sign up for free
Drill 6: A slow copy
Waiting time instead of errors: a pod that answers every request only
after two seconds (nginx in front of go-httpbin with
/delay/2).
# on s1
kubectl -n kurz delete deploy kurz-kaputt
cat > kurz-langsam.yaml <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
name: kurz-langsam
namespace: kurz
data:
default.conf: |
server {
listen 8080;
location / { rewrite ^ /delay/2 break; proxy_pass http://127.0.0.1:8081; }
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kurz-langsam
namespace: kurz
spec:
replicas: 1
selector:
matchLabels:
app: kurz
variante: langsam
template:
metadata:
labels:
app: kurz
variante: langsam
annotations:
linkerd.io/inject: enabled
spec:
containers:
- name: nginx
image: nginx:1.30.8-alpine
ports:
- name: http
containerPort: 8080
volumeMounts:
- name: conf
mountPath: /etc/nginx/conf.d
- name: httpbin
image: mccutchen/go-httpbin:2.26.0
env:
- name: PORT
value: "8081"
volumes:
- name: conf
configMap:
name: kurz-langsam
EOF
kubectl apply -f kurz-langsam.yaml && kubectl -n kurz rollout status deploy kurz-langsam
# checked directly: two seconds
curl -s -o /dev/null -w 'direkt: %{http_code} %{time_total}s\n' http://$(kubectl -n kurz get pods -l variante=langsam -o jsonpath='{.items[0].status.podIP}'):8080/abc
sleep 10
echo "== im Mesh"; mesh -e RATE=200 -e DAUER=30s 2>&1 | zaehle
echo "== über das Gateway"; k6 run -q -e ZIEL=http://172.16.0.126 -e RATE=200 -e DAUER=30s status2.js 2>&1 | zaehleExpected:
direkt: 200 2.013113s
== im Mesh
http_req_duration ✓ 'p(95)>=0' p(95)=25.91ms
http_reqs{status:200} ✓ 'count>=0' count=7
http_reqs{status:302} ✓ 'count>=0' count=5993
== über das Gateway
http_req_duration ✓ 'p(95)>=0' p(95)=2.01s
http_reqs{status:200} ✓ 'count>=0' count=651
http_reqs{status:302} ✓ 'count>=0' count=5350
The difference lies in load balancing. The Linkerd proxy measures the
latency of every endpoint and sends almost nothing to the slow one – 7
out of 6000. Envoy balances by the number of open requests
(LeastRequest, Day 3) and does not notice slowness: 651
requests wait two seconds, and the p95 of all users is 2.01 s.
Happened during testing: The first version had
proxy_pass http://127.0.0.1:8081/delay/2;. With a path after the address, nginx only replaces the prefix of thelocation–/abcbecame/delay/2abc, and go-httpbin answered with400. A “slow” pod that returns errors quickly measures something completely different. That is why the direct call with timing is up there.
The seven slow requests in the mesh can be avoided too: a timeout per attempt turns a slow response into an error that the retry passes on to another pod.
# on s1
# 300 ms per attempt, at most 1 s for the whole request
sed 's/ retry.linkerd.io\/limit: "2"/ retry.linkerd.io\/limit: "2"\n retry.linkerd.io\/timeout: 300ms\n timeout.linkerd.io\/request: 1s/' route-retry.yaml > route-timeout.yaml
kubectl apply -f route-timeout.yaml && sleep 8
for i in 1 2; do mesh -e RATE=200 -e DAUER=30s --summary-trend-stats 'p(95),p(99),max' 2>&1 \
| grep -E 'http_reqs\{status:(200|302)\}|^ *http_req_duration\.' -A1 | grep -E "count=[1-9]|http_req_duration\." | sed 's/ */ /g'; doneExpected:
httproute.gateway.networking.k8s.io/kurz-mesh configured
✓ 'count>=0' count=6000
http_req_duration..............: p(95)=22.03ms p(99)=54.32ms max=390.35ms
✓ 'count>=0' count=6001
http_req_duration..............: p(95)=35.93ms p(99)=125.73ms max=405.66ms
No request waits two seconds anymore: at most 300 ms for the first attempt plus the second one.
Save your progress? Sign up for free
Exercise: Speed drills
- Is the control plane healthy, and do all pods of
kurzhave a proxy? Target time: 1 min - Which retries and timeouts apply to callers in the mesh? Target time: 1 min
- A colleague asks: “We have retries in the mesh – so why do users at the gateway still see 503?” Answer in two sentences. Target time: 2 min
Solution
# on s1
# 1: control plane and proxies
linkerd check | tail -1
kubectl -n kurz get pods -l app=kurz -o jsonpath='{range .items[*]}{.metadata.name} {.status.initContainerStatuses[?(@.name=="linkerd-proxy")].ready}{"\n"}{end}'
# 2: annotations of the route
kubectl -n kurz get httproute kurz-mesh -o jsonpath='{.metadata.annotations}' | jq -c 'with_entries(select(.key|startswith("retry") or startswith("timeout")))'Expected:
Status check results are √
kurz-77c9dc76b4-4zv9k true
kurz-77c9dc76b4-dptt7 true
{"retry.linkerd.io/http":"5xx","retry.linkerd.io/limit":"2","retry.linkerd.io/timeout":"300ms","timeout.linkerd.io/request":"1s"}
On 3: retries in the mesh are done by the caller’s proxy. Envoy at
the gateway has no Linkerd proxy; for it, only the rules of the
BackendTrafficPolicy apply – that is where the protection
for users must live.
Save your progress? Sign up for free
Challenge
Make the path through the gateway as robust against the slow copy as the mesh, without bringing Envoy into the mesh. Goal: no user waits longer than half a second.
Solution
Envoy cannot balance by latency, but it can give every attempt a
deadline and retry once it expires. Two things are added to the policy
from Day 11: perRetry.timeout and the trigger
gateway-error (an expired attempt counts as one).
# on s1
python3 - <<'EOF'
s = open("../tag11/schutz-ende.yaml").read()
alt = " - connect-failure\n - refused-stream\n"
neu = alt + " - gateway-error\n perRetry:\n timeout: 300ms\n"
open("schutz-tag12.yaml", "w").write(s.replace(alt, neu, 1))
EOF
diff ../tag11/schutz-ende.yaml schutz-tag12.yaml
kubectl apply -f schutz-tag12.yaml && sleep 15
for i in 1 2; do k6 run -q -e ZIEL=http://172.16.0.126 -e RATE=200 -e DAUER=30s --summary-trend-stats 'p(95),p(99),max' status2.js 2>&1 \
| grep -E 'http_reqs\{status:(200|302)\}|^ *http_req_duration\.' -A1 | grep -E "count=[1-9]|http_req_duration\." | sed 's/ */ /g'; doneExpected:
16a17,19
> - gateway-error
> perRetry:
> timeout: 300ms
backendtrafficpolicy.gateway.envoyproxy.io/kurz-retry configured
✓ 'count>=0' count=6001
http_req_duration..............: p(95)=21.42ms p(99)=54.39ms max=342.85ms
✓ 'count>=0' count=6001
http_req_duration..............: p(95)=17.98ms p(99)=36.02ms max=343.59ms
At most 344 ms, p95 under 22 ms – as good as in the mesh. The price is the same as there: every slow response costs a second attempt, and retries without a limit can knock a struggling backend over for good (Day 11: that is why the circuit breaker stays in).
# on s1
# clean up: slow copy gone, KEDA scales again
kubectl -n kurz delete deploy kurz-langsam && kubectl -n kurz delete cm kurz-langsam kurz-kaputt
kubectl -n kurz annotate scaledobject kurz autoscaling.keda.sh/paused-replicas-Save your progress? Sign up for free
Checkpoint
# on s1
# control plane healthy
linkerd check | tail -1
# kurz with proxy
kubectl -n kurz get pods -l app=kurz -o jsonpath='{range .items[*]}{.metadata.name} {.status.initContainerStatuses[?(@.name=="linkerd-proxy")].ready}{"\n"}{end}'
# circuit breaking in the mesh
kubectl -n kurz get svc kurz -o jsonpath='{.metadata.annotations.balancer\.linkerd\.io/failure-accrual}{"\n"}'
# gateway: deadline per attempt and triggers
kubectl -n kurz get btp kurz-retry -o jsonpath='{.spec.retry.perRetry.timeout} {.spec.retry.retryOn.triggers}{"\n"}'
# no more test copies behind the Service: only the two pods of kurz
kubectl -n kurz get pods -l app=kurz -o name | wc -lExpected:
Status check results are √
kurz-77c9dc76b4-4zv9k true
kurz-77c9dc76b4-dptt7 true
consecutive
300ms ["connect-failure","refused-stream","gateway-error"]
2
Interview note
- What does a mesh bring? mTLS with identity without code changes, retries and timeouts at the caller, load balancing by latency. Here: a slow pod got 7 out of 6000 requests in the mesh, 651 through Envoy.
- What does it cost? Here almost as much CPU as the app itself (~400m per proxy at 500 requests per second and pod) and 40–90 ms more p95 on a tight lab. Introducing a mesh is a capacity decision.
- Fast errors attract load: a latency-based balancer
prefers a pod that returns
503immediately. Without circuit breaking, a third became 60 % errors. - Retries belong where the caller sits. Mesh retries protect calls between pods, not users at the gateway. For both: deadline per attempt, upper limit, circuit breaker.
Enterprise note
- mTLS in the mesh often satisfies the audit requirement “encryption inside the cluster”. The gaps are what matters: traffic from components outside the mesh (here Envoy, databases, NATS) stays plaintext until it speaks TLS itself.
- Retries are only safe for idempotent requests. Linkerd does not retry requests with a body without an explicit setting; Envoy does, if you configure it that way. A platform needs rules per route for this, not a global switch.
- Retries multiply across layers: gateway, mesh and client library with two retries each, i.e. three attempts each, give 3 × 3 × 3 = 27 attempts per click in the worst case. Retry budgets and deadlines must be planned across all layers.