Skip to content
System design on Kubernetes · Chapter 17 of 20 Day 15: Competition – the overloaded cluster

Day 15: Competition – the overloaded cluster

Goal: In six rounds, find and fix faults in the running cluster, each from one day of the course, against the clock and with the measurement as proof · Duration: approx. 90 min · Prerequisite: Days 0–14

Briefing

  • An evening on the cluster from Day 14. Six times someone changes something, the way a colleague, a pipeline or a poorly tested update does. Nobody tells you what. You see what a user sees – and what the tools of the last weeks show.
  • Each fault comes from one day: requests and limits (Day 2/9), rate limiting (Day 11), KEDA (Day 10), network and cache (Day 5), database and pooler (Day 7), backpressure and autoscaling (Day 10/11).
  • Tools: everything you know – k6, kubectl, Envoy’s statistics, nats, psql. Nothing new.
Round  Symptom                                                              Target time
1      Almost all requests fail, all Pods are running                       5 min
2      A customer gets an answer on every tenth request, otherwise 429      4 min
3      Everything runs, but the click counts stand still                    4 min
4      A rollout makes no progress                                          5 min
5      Redirects work, new links do not                                     4 min
6      Under load, every twentieth request fails                            6 min

Rules of the game

  • In each round, the referee runs their commands – a colleague or you yourself, without looking: copy the block into a second terminal, run it, close the window. Then start the clock.
  • Find the cause, fix it, prove it with the measurement. Only then stop the clock.
  • Fix the cause, not the symptom. Anyone who removes the rate limit entirely, tears down KEDA or deletes the circuit breaker gets zero points for the round.
  • Read the hint only after the target time has run out.
  • All commands run on s1, KUBECONFIG is set.

Playing field

# on s1
mkdir -p ~/sdk/tag15 && cd ~/sdk/tag15
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
cp ../tag14/mix.js ../tag14/codes.txt ../tag11/status.js .
# Function messen: mix of redirects and link creation, rate and duration selectable
messen() { k6 run -q -e ZIEL=http://172.16.0.126 -e RATE=${1:-400} -e DAUER=${2:-20s} mix.js 2>&1 \
  | grep -E 'http_req_duration\.|http_req_failed\.|http_reqs\.' | sed 's/  */ /g'; }
# Function st: count and p95 per status code, pass on further k6 options
st() { k6 run -q -e ZIEL=http://172.16.0.126 -e DAUER=20s "$@" status.js 2>&1 \
  | grep -A1 -E '\{status:(302|429|503)\}' | sed 's/  */ /g' | grep -v '^--' | paste - - | grep -v 'count=0\|p(95)=0s' | awk '{print $1, $NF}'; }
# Starting point
messen

Expected:

 http_req_duration...: avg=15.68ms min=3.68ms med=11.95ms max=220.29ms p(90)=27.2ms p(95)=36.13ms
 http_req_failed.....: 0.00% 0 out of 7999
 http_reqs...........: 7999 399.836669/s

Round 1: Errors although everything is running

Referee:

# on s1
kubectl -n kurz set resources deploy kurz -c kurz --requests=cpu=100m --limits=cpu=150m >/dev/null
kubectl -n kurz rollout status deploy kurz >/dev/null
clear

Task: Almost all requests fail, kubectl get pods shows only running Pods. Find the cause and prove the repair. Target time: 5 min

Hint: What changed in the Pod template, and what does that have to do with Day 2?

Solution Round 1

# on s1
messen
kubectl -n kurz get deploy kurz -o jsonpath='{.spec.template.spec.containers[0].resources}{"\n"}'

Expected:

 http_req_duration...: avg=522.87ms min=837.14µs med=634.28ms max=1.26s p(90)=1s p(95)=1.06s
 http_req_failed.....: 95.03% 7319 out of 7701
 http_reqs...........: 7701 367.331447/s
{"limits":{"cpu":"150m","memory":"64Mi"},"requests":{"cpu":"100m","memory":"32Mi"}}

A CPU limit of 150m: every Pod is throttled (Day 2), requests pile up, and the circuit breaker from Day 11 rejects the rest. The obvious way back fails:

# on s1
kubectl apply -f ../tag13/kurz-ende.yaml

Expected:

The Deployment "kurz" is invalid: spec.template.spec.containers[0].resources.requests: Invalid value: "250m": must be less than or equal to cpu limit of 150m

The trap from Day 2: the limit came with kubectl set, not from the file. It is not in the last-applied-configuration annotation, so apply considers it foreign and leaves it in place – and the request from the file is larger than the remaining limit. First remove the limit specifically, then apply the file:

# on s1
kubectl -n kurz patch deploy kurz --type json -p '[{"op":"remove","path":"/spec/template/spec/containers/0/resources/limits/cpu"}]'
kubectl apply -f ../tag13/kurz-ende.yaml >/dev/null && kubectl -n kurz rollout status deploy kurz >/dev/null
kubectl -n kurz get deploy kurz -o jsonpath='{.spec.template.spec.containers[0].resources}{"\n"}'
sleep 10; messen

Expected:

deployment.apps/kurz patched
{"limits":{"memory":"64Mi"},"requests":{"cpu":"250m","memory":"32Mi"}}
 http_req_duration...: avg=15.3ms min=3.46ms med=11.21ms max=256.99ms p(90)=27.82ms p(95)=39.43ms
 http_req_failed.....: 0.00% 0 out of 8001
 http_reqs...........: 8001 399.925223/s

Save your progress? Sign up for free

Round 2: Customers left outside

Referee:

# on s1
kubectl -n kurz patch btp kurz-retry --type json -p '[{"op":"replace","path":"/spec/rateLimit/global/rules/0/limit/requests","value":5}]' >/dev/null
clear

Task: Five customers who identify themselves with X-Nutzer get almost nothing but 429. Anonymous users notice nothing. Target time: 4 min

Hint: Who sends 429, and with which limit? Day 11.

Solution Round 2

# on s1
sleep 15
echo "== fünf Kunden"; st -e RATE=300 -e NUTZER=5
echo "== anonym"; st -e RATE=300
kubectl -n kurz get btp kurz-retry -o jsonpath='{.spec.rateLimit.global.rules[0]}{"\n"}'

Expected:

== fünf Kunden
http_reqs{status:302} count=525
http_reqs{status:429} count=5476
== anonym
http_reqs{status:302} count=6001
{"clientSelectors":[{"headers":[{"invert":false,"name":"X-Nutzer","type":"Distinct"}]}],"limit":{"requests":5,"unit":"Second"}}

Five instead of fifty per second and user (“fünf Kunden” = five customers). Repair: apply the policy from the repository again (Day 12), then check that the limit still works – five customers with 60 per second each may have 50 each:

# on s1
kubectl apply -f ../tag12/schutz-tag12.yaml && sleep 15
st -e RATE=300 -e NUTZER=5

Expected:

backendtrafficpolicy.gateway.envoyproxy.io/kurz-retry configured
http_reqs{status:302} count=5048
http_reqs{status:429} count=953

About 5 × 50 × 20 = 5000 redirects, the rest 429 – that is how it should be. Anyone who had deleted the limit would have seen 6000 here and got zero points.

Save your progress? Sign up for free

Round 3: The numbers stand still

Referee:

# on s1
kubectl -n kurz annotate scaledobject zaehler autoscaling.keda.sh/paused-replicas=0 --overwrite >/dev/null
clear

Task: Users see no errors, but the click counts in the database no longer move. Target time: 4 min

Hint: Where do clicks wait before they are counted, and who picks them up? Days 8 and 10.

Solution Round 3

# on s1
N="nats -s nats://kurz:lab-nats-123@$(kubectl -n nats get svc nats -o jsonpath='{.spec.clusterIP}'):4222"
P=$(kubectl -n kurz get cluster db -o jsonpath='{.status.currentPrimary}')
summe() { kubectl -n kurz exec $P -c postgres -- psql -d kurz -tAc 'SELECT coalesce(sum(anzahl),0) FROM klicks'; }
A=$(summe); messen 300 20s | grep failed; sleep 5
echo "gezählt in 20 s: $(( $(summe) - A )), offen: $($N consumer info KLICKS zaehler --json | jq .num_pending)"
kubectl -n kurz get scaledobject zaehler -o custom-columns=NAME:.metadata.name,MIN:.spec.minReplicaCount,PAUSED:.status.conditions[?\(@.type==\"Paused\"\)].status --no-headers

Expected:

 http_req_failed.....: 0.00% 0 out of 6001
gezählt in 20 s: 0, offen: 5417
zaehler   0     True

gezählt means counted, offen means pending. Zero workers are normal with minReplicaCount: 0 – that is what makes this fault treacherous. The giveaway is the backlog that does not shrink, and Paused=True. Repair and proof:

# on s1
kubectl -n kurz annotate scaledobject zaehler autoscaling.keda.sh/paused-replicas-
for i in $(seq 1 12); do o=$($N consumer info KLICKS zaehler --json | jq .num_pending); echo "$((i*5))s offen=$o pods=$(kubectl -n kurz get deploy zaehler -o jsonpath='{.status.readyReplicas}')"; [ "$o" = 0 ] && break; sleep 5; done

Expected:

scaledobject.keda.sh/zaehler annotated
5s offen=5417 pods=
10s offen=5017 pods=1
15s offen=4417 pods=1
20s offen=3817 pods=3
25s offen=2217 pods=3
30s offen=517 pods=3
35s offen=0 pods=3

Save your progress? Sign up for free

Round 4: The rollout that never arrives

Referee:

# on s1
cat <<'EOF' | kubectl apply -f - >/dev/null
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: valkey-nur-intern
  namespace: kurz
spec:
  podSelector:
    matchLabels:
      app.kubernetes.io/name: valkey
  policyTypes: ["Ingress"]
  ingress:
  - from:
    - podSelector:
        matchLabels:
          app.kubernetes.io/name: valkey
EOF
clear

Task: Users notice nothing. Start a rollout of kurz (kubectl -n kurz rollout restart deploy kurz) – it makes no progress. Why? Target time: 5 min

Hint: What is the first thing kurz does at startup? And why do the old Pods keep running?

Solution Round 4

# on s1
messen 300 20s | grep failed
kubectl -n kurz rollout restart deploy kurz
kubectl -n kurz rollout status deploy kurz --timeout=240s 2>&1 | tail -1
kubectl -n kurz get pods -l app=kurz --no-headers | awk '{print $1, $2, $3}'
P=$(kubectl -n kurz get pods -l app=kurz --no-headers | awk '/CrashLoop|Error/{print $1; exit}')
kubectl -n kurz logs $P -c kurz --previous | tail -2
kubectl get netpol -A

Expected:

 http_req_failed.....: 0.00% 0 out of 6000
deployment.apps/kurz restarted
error: timed out waiting for the condition
kurz-5b57585b5d-cc6p2 1/2 CrashLoopBackOff
kurz-6bf4fbc7f6-7kh89 2/2 Running
kurz-6bf4fbc7f6-lblt7 2/2 Running
kurz-6bf4fbc7f6-rz5x5 2/2 Running
2026/11/25 22:54:14 kurz-5b57585b5d-cc6p2: 1 Shard(s)
2026/11/25 22:54:14 cache: read tcp 10.42.4.133:49456->10.42.2.123:6379: read: connection reset by peer
NAMESPACE   NAME                POD-SELECTOR                    AGE
kurz        valkey-nur-intern   app.kubernetes.io/name=valkey   31s

Three lessons in one round. First, a NetworkPolicy only affects new connections: the old Pods keep their connections to Valkey in the pool, and the packet filter lets existing connections through. That is why users noticed nothing. Second, kurz checks the cache at startup and exits without it. Third, the rollout strategy (maxUnavailable: 25 %) keeps the old Pods alive as long as the new one is not ready – a broken rollout does no harm, but it stays stuck until someone looks.

# on s1
kubectl -n kurz delete netpol valkey-nur-intern
kubectl -n kurz rollout status deploy kurz --timeout=240s | tail -1

Expected:

networkpolicy.networking.k8s.io "valkey-nur-intern" deleted from kurz namespace
deployment "kurz" successfully rolled out

Save your progress? Sign up for free

Round 5: No new links

Referee:

# on s1
kubectl -n kurz patch pooler db-pooler-rw --type merge -p '{"spec":{"instances":0}}' >/dev/null
clear

Task: Redirects work, but every tenth request fails. Target time: 4 min

Hint: Which requests are the ten percent? Which path do they take (Day 7)?

Solution Round 5

# on s1
sleep 20
k6 run -q -e ZIEL=http://172.16.0.126 -e RATE=300 -e DAUER=20s mix.js 2>&1 | grep -E '✓ 302|✗ 302|✗ 201|http_req_failed\.' | sed 's/  */ /g'
kubectl -n kurz get pooler db-pooler-rw -o jsonpath='instances={.spec.instances}{"\n"}'
kubectl -n kurz logs -l app=kurz -c kurz --since=40s --tail=300 | grep -v weiterleiten | sed -E 's/^[0-9\/: ]+//; s/kurz-[a-z0-9-]+: //' | sort | uniq -c | sort -rn | head -3

Expected:

 ✓ 302
 ✗ 201
 http_req_failed.....: 10.06% 604 out of 6001
instances=0
     43 anlegen: context canceled
      5 anlegen: failed to connect to `user=kurz database=kurz`:
      3 Sicherung offen für 5s (9 Fehler in Folge)

Exactly the ten percent of link creation (anlegen): writes go through the pooler (Day 7), and it no longer has an instance. Reads keep running via the cache and db-ro. The circuit breaker from the predecessor course opens after nine errors in a row (“Sicherung offen für 5s (9 Fehler in Folge)” = circuit breaker open for 5 s, 9 errors in a row). Repair:

# on s1
kubectl -n kurz patch pooler db-pooler-rw --type merge -p '{"spec":{"instances":2}}'
kubectl -n kurz rollout status deploy db-pooler-rw --timeout=120s | tail -1
sleep 10; messen 300 20s | grep failed

Expected:

pooler.postgresql.cnpg.io/db-pooler-rw patched
deployment "db-pooler-rw" successfully rolled out
 http_req_failed.....: 0.01% 1 out of 6000

The 201 check in mix.js still stays red afterwards: the script creates the same URLs in every run (/neu/<VU>-<iteration>), and kurz answers an already known URL with 200. The yardstick here is the error rate, not the check.

Save your progress? Sign up for free

Round 6: Every twentieth request

Referee:

# on s1
kubectl -n kurz annotate scaledobject kurz autoscaling.keda.sh/paused-replicas=1 --overwrite >/dev/null
kubectl -n kurz patch btp kurz-retry --type merge -p '{"spec":{"circuitBreaker":{"maxParallelRequests":5}}}' >/dev/null
clear

Task: At 500 requests per second, every twentieth fails with 503, fast. Two things are broken. Target time: 6 min

Hint: A fast 503 does not come from kurz. And how many kurz are actually running?

Solution Round 6

# on s1
sleep 30; st -e RATE=500
kubectl -n kurz get deploy kurz -o jsonpath='kurz-Pods={.status.readyReplicas}{"\n"}'
kubectl -n kurz get scaledobject kurz -o jsonpath='paused={.metadata.annotations.autoscaling\.keda\.sh/paused-replicas}{"\n"}'
kubectl -n kurz get btp kurz-retry -o jsonpath='{.spec.circuitBreaker}{"\n"}'
# Envoy counts how often the circuit breaker rejected
for p in $(kubectl -n envoy-gateway-system get pods -l gateway.envoyproxy.io/owning-gateway-name=web -o name); do
  kubectl -n envoy-gateway-system port-forward $p 19000:19000 >/dev/null 2>&1 & PF=$!; sleep 2
  curl -s localhost:19000/stats | grep -E 'httproute/kurz.*upstream_rq_pending_overflow:'; kill $PF; sleep 1
done

Expected (Envoy’s counters have been running since the Pods started):

http_req_duration{status:302} p(95)=22.23ms
http_req_duration{status:503} p(95)=21.58ms
http_reqs{status:302} count=9582
http_reqs{status:503} count=418
kurz-Pods=1
paused=1
{"maxConnections":1024,"maxParallelRequests":5,"maxParallelRetries":1024,"maxPendingRequests":20}
cluster.httproute/kurz/kurz/rule/0.upstream_rq_pending_overflow: 2754
cluster.httproute/kurz/kurz/rule/0.upstream_rq_pending_overflow: 3931

One kurz Pod instead of three (KEDA paused) and a circuit breaker with 5 instead of 100 parallel requests: Envoy rejects whatever does not fit into the queue (pending_overflow). Each fault on its own would hardly have been noticed. Repair both, then the proof:

# on s1
kubectl -n kurz annotate scaledobject kurz autoscaling.keda.sh/paused-replicas-
kubectl apply -f ../tag12/schutz-tag12.yaml
sleep 40
kubectl -n kurz get deploy kurz -o jsonpath='kurz-Pods={.status.readyReplicas}{"\n"}'
st -e RATE=500

Expected:

scaledobject.keda.sh/kurz annotated
backendtrafficpolicy.gateway.envoyproxy.io/kurz-retry configured
kurz-Pods=3
http_req_duration{status:302} p(95)=54.7ms
http_reqs{status:302} count=10001

Save your progress? Sign up for free

Scoring

Round Target time Points if solved within target time with hint
1 CPU limit and the apply trap 5 min 3 1
2 Rate limit 4 min 2 1
3 KEDA paused 4 min 2 1
4 NetworkPolicy and rollout 5 min 3 1
5 Pooler 4 min 2 1
6 Double fault 6 min 3 1

15 points are possible. From 12 up, you have the course under control; below 8, it is worth going through the days of the missed rounds again.

Checkpoint

# on s1
# everything back to the target state: three kurz Pods, no CPU limit, limit 50/s, CB 100, pooler 2, KEDA not paused
kubectl -n kurz get deploy kurz -o jsonpath='{.status.readyReplicas} {.spec.template.spec.containers[0].resources.limits}{"\n"}'
kubectl -n kurz get btp kurz-retry -o jsonpath='{.spec.rateLimit.global.rules[0].limit.requests} {.spec.circuitBreaker.maxParallelRequests}{"\n"}'
kubectl -n kurz get pooler db-pooler-rw -o jsonpath='{.spec.instances}{"\n"}'
kubectl -n kurz get scaledobjects -o custom-columns=NAME:.metadata.name,PAUSED:.metadata.annotations.autoscaling\\.keda\\.sh/paused-replicas --no-headers
kubectl get netpol -A 2>&1 | tail -1

Expected:

3 {"memory":"64Mi"}
50 100
2
kurz      <none>
zaehler   <none>
No resources found

Interview note

  • “All Pods are running, but nothing works.” First break the errors down by kind and status code: a fast 503 comes from the Gateway (Round 6), a 429 from the rate limit (Round 2), a slow failure from inside the Pod (Round 1). Each layer has its own counter.
  • Configuration drift is the most common fault. All six rounds were changes to the running system, not defects. kubectl set, annotate, patch alongside apply create exactly the deviations that apply later no longer finds (Round 1).
  • Silent faults need their own signals. Rounds 3 and 4 showed users nothing: a backlog that does not shrink, a stuck rollout. Both need an alert, otherwise they are noticed only days later.

Enterprise note

  • An evening like this is called a game day: planned, with a referee, measurement and a debrief. Each round turns into an alert and a runbook entry.
  • GitOps with drift detection (Argo CD, Flux) would have reverted, or at least reported, five of the six rounds within minutes – the NetworkPolicy from Round 4 only if it did not also come from the repository.
  • Rollouts need a deadline with an alert (progressDeadlineSeconds plus monitoring of the Progressing=False condition), otherwise a broken rollout like the one in Round 4 stays silently stuck.

Contents

More