Skip to content
System design · Chapter 18 of 21 Day 16: Competition – the Overloaded System

Day 16: Competition – the Overloaded System

Goal: In five rounds, find and fix faults in the running system, each from a topic of the book, against the clock and with the measurement as proof · Duration: approx. 90 min · Prerequisite: Days 0–15

Briefing

  • An evening under load: 1200 redirects per second, plus a customer creating 20 links per second. Five times something goes wrong. Nobody tells you what. You only see what a user sees: errors, waiting times, numbers that don’t add up.
  • Each fault comes from a day of the book: scaling (Day 3), database (Day 7), cache (Days 5 and 6), rate limiting (Day 12), queue (Day 10).
  • Tools: everything you know. k6, the HAProxy statistics, journalctl, psql, valkey-cli, nats, systemctl. No new tool, just the question: where is it stuck?
Round  Symptom                                                    Target time
1      Errors and long waits, all services running                5 min
2      The customer can no longer create links                    5 min
3      Everything is slower, the database is very busy            5 min
4      The customer is turned away on every second request        4 min
5      The click counts in the customer portal lag behind         4 min

Rules of the game

  • In each round, the referee runs their commands, a colleague or you yourself without looking: copy the block, paste it into a second terminal, 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 quota entirely, rips the circuit breaker out of kurz or switches off the cache gets zero points for the round.
  • Read the hint only after the target time has run out.
  • All commands run on s1 unless stated otherwise.

Playing field

One load test for the whole evening, two scenarios in one file. klick calls popular links much more often than rare ones, like klick.js since Day 10. anlegen sends the key of the customer abend, like anlegen.js since Day 12:

# on s1
mkdir -p ~/sd/tag16 && cd ~/sd/tag16
cp ~/sd/tag15/codes.txt .
cat > wettkampf.js <<'EOF'
import http from "k6/http";
import { check } from "k6";
import { SharedArray } from "k6/data";

const codes = new SharedArray("codes", () => open("./codes.txt").split("\n").filter(Boolean));
const ZIEL = __ENV.ZIEL || "http://localhost";
const DAUER = __ENV.DAUER || "30s";

// Der Abend: viele Weiterleitungen ohne Schlüssel, dazu ein Kunde, der Links anlegt
export const options = {
  scenarios: {
    klicks: {
      executor: "constant-arrival-rate", exec: "klick",
      rate: 1200, timeUnit: "1s", duration: DAUER, preAllocatedVUs: 50, maxVUs: 500,
    },
    anlegen: {
      executor: "constant-arrival-rate", exec: "anlegen",
      rate: 20, timeUnit: "1s", duration: DAUER, preAllocatedVUs: 10, maxVUs: 200,
    },
  },
};

export function klick() {
  const code = codes[Math.floor(Math.pow(Math.random(), 3) * codes.length)];
  const r = http.get(`${ZIEL}/${code}`, { redirects: 0, tags: { art: "klick" } });
  check(r, { "klick 302": (x) => x.status === 302 });
}

export function anlegen() {
  const url = `https://example.org/tag16/${__VU}-${__ITER}-${Date.now()}`;
  const r = http.post(`${ZIEL}/api/links`, JSON.stringify({ url }), {
    headers: { "Content-Type": "application/json", "X-Api-Key": "abend" },
    tags: { art: "anlegen" }, timeout: "10s",
  });
  check(r, { "anlegen 201": (x) => x.status === 201 });
}
EOF

The measurement after each round: 30 seconds of load and the counter’s backlog:

# on s1
cd ~/sd/tag16
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
nats consumer info KLICKS zaehler --json | jq .num_pending

The first run after a break fills the cache; one to two percent errors are normal there (Day 15). The second run shows the healthy state:

Expected:

    checks_failed......: 0.00%  0 out of 36596
    http_req_duration..............: avg=5.23ms min=868.5µs med=3.56ms max=68.9ms  p(90)=10.25ms p(95)=14.6ms
0

Healthy means: checks_failed below 0.1%, p95 below 30 ms and 0 messages in the backlog. A line with ↳ only appears when a check fails.

Round 1: Errors Although Everything Is Running

Referee:

# on s2
printf '[Service]\nCPUQuota=10%%\n' | sudo tee /etc/systemd/system/kurz.service.d/sparen.conf >/dev/null
sudo systemctl daemon-reload
clear

Task: A colleague reports errors and long waiting times. systemctl shows only running services on all three machines. Find the cause. Target time: 5 min

Hint: Do both instances get the same share? Day 3.

Solution Round 1

# on s1
cd ~/sd/tag16
echo "clear counters all" | sudo socat stdio /run/haproxy/admin.sock
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
echo "show stat" | sudo socat stdio /run/haproxy/admin.sock | awk -F, '$1 == "kurz" {print $2, $8, $44, $62}'

Expected:

    checks_failed......: 5.72%  2061 out of 36002
    ✗ klick 302
      ↳  94% — ✓ 33378 / ✗ 2024
    ✗ anlegen 201
      ↳  93% — ✓ 563 / ✗ 37
    http_req_duration..............: avg=28.77ms min=853.06µs med=14.12ms max=410.38ms p(90)=93.98ms p(95)=108.63ms
s1 27590 0 79
s2 6351 0 155
BACKEND 36002 2061 95

The columns are name, total requests (stot), responses with 5xx (hrsp_5xx) and mean total time in milliseconds (ttime). s2 got only a fifth of the requests and takes twice as long. leastconn (Day 3) sends new requests to the server with the fewest open connections. A slow server holds its connections longer and therefore gets less. The 2061 errors appear only at the backend: those are the 503s from load shedding (Day 12), because s1 can’t handle the load alone. What is slowing s2 down?

# on s1
for h in s1 s2; do ssh $h "hostname; systemctl show kurz -p CPUQuotaPerSecUSec"; done
ssh s2 "grep -H CPUQuota /etc/systemd/system/kurz.service.d/*.conf"

Expected:

s1
CPUQuotaPerSecUSec=500ms
s2
CPUQuotaPerSecUSec=100ms
/etc/systemd/system/kurz.service.d/cpu.conf:CPUQuota=50%
/etc/systemd/system/kurz.service.d/sparen.conf:CPUQuota=10%

Two drop-ins set the same value. systemd reads them in alphabetical order, and the last one wins: sparen.conf after cpu.conf, so 10% of a core instead of 50%. The file has to go:

# on s1
ssh s2 "sudo rm /etc/systemd/system/kurz.service.d/sparen.conf && sudo systemctl daemon-reload && systemctl show kurz -p CPUQuotaPerSecUSec"
echo "clear counters all" | sudo socat stdio /run/haproxy/admin.sock
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
echo "show stat" | sudo socat stdio /run/haproxy/admin.sock | awk -F, '$1 == "kurz" {print $2, $8, $44, $62}'

Expected:

CPUQuotaPerSecUSec=500ms
    checks_failed......: 0.00%   0 out of 36603
    http_req_duration..............: avg=5.17ms min=925.64µs med=3.59ms max=58.58ms p(90)=10.06ms p(95)=14.21ms
s1 19156 0 47
s2 17447 0 51
BACKEND 36603 0 49

No restart needed: daemon-reload applies the new limit to the running cgroup immediately.

Save your progress? Sign up for free

Round 2: No New Links

Referee:

# on s1
PGPASSWORD=lab-kurz-123 psql -h s3 -U kurz -d kurz -qc "drop index links_url_idx"
clear

Task: The customer abend reports that they can hardly create links anymore. In the afternoon, a colleague “tidied up the database a bit”. Target time: 5 min

Hint: What does anlegen do first, before it writes a new link? Day 7.

Solution Round 2

# on s1
cd ~/sd/tag16
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
journalctl -u kurz --since -1min --no-pager | tail -3

Expected:

    checks_failed......: 4.40%  1610 out of 36559
    ✗ klick 302
      ↳  97% — ✓ 34944 / ✗ 1035
    ✗ anlegen 201
      ↳  0% — ✓ 5 / ✗ 575
    http_req_duration..............: avg=12.92ms min=648.61µs med=4.44ms max=2.02s p(90)=20.29ms p(95)=23.74ms
Nov 23 23:15:57 s1 kurz[58435]: 2026/11/23 23:15:57 s1: Sicherung offen für 5s (16 Fehler in Folge)
Nov 23 23:15:58 s1 kurz[58435]: 2026/11/23 23:15:58 anlegen: timeout: context deadline exceeded
Nov 23 23:15:58 s1 kurz[58435]: 2026/11/23 23:15:58 s1: Sicherung offen für 5s (17 Fehler in Folge)

Five out of 580 links created. The requests run into the 2-second timeout (Day 13), then the circuit breaker opens and rejects immediately. That works as built. The redirects suffer anyway: 1035 errors, because hanging create requests occupy slots of the maxconn 16, the cascade from Day 13 in miniature. The first query when creating a link is the dedupe lookup from Day 7:

# on s1
export PGPASSWORD=lab-kurz-123
psql -h s3 -U kurz -d kurz -c "explain (analyze, costs off) SELECT code FROM links WHERE url = 'https://example.org/gibtsnicht' LIMIT 1" | grep -E 'Seq|Index|Execution'
psql -h s3 -U kurz -d kurz -c '\di links*'

Expected:

         ->  Parallel Seq Scan on links (actual time=488.695..488.696 rows=0.00 loops=3)
 Execution Time: 523.829 ms
                List of indexes
 Schema |     Name      | Type  | Owner | Table
--------+---------------+-------+-------+-------
 public | links_pkey    | index | kurz  | links
 public | links_url_neu | index | kurz  | links
(2 rows)

Half a second per lookup, because PostgreSQL reads all 2.6 million rows. 20 requests per second times 0.5 seconds makes 10 scans running at the same time (Little’s Law, Day 2), more than the database can cope with in parallel. The partial index links_url_neu doesn’t help: it only knows links from Day 11 on, and the query doesn’t ask about the date. Recreate the index, with CONCURRENTLY, so that link creation keeps running in the meantime:

# on s1
psql -h s3 -U kurz -d kurz -c '\timing on' -c "create index concurrently links_url_idx on links (url)"
psql -h s3 -U kurz -d kurz -c "explain (analyze, costs off) SELECT code FROM links WHERE url = 'https://example.org/gibtsnicht' LIMIT 1" | grep -E 'Seq|Index Scan|Execution'
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'

Expected:

Timing is on.
CREATE INDEX
Time: 9728.670 ms (00:09.729)
   ->  Index Scan using links_url_idx on links (actual time=0.134..0.134 rows=0.00 loops=1)
 Execution Time: 0.219 ms
    checks_failed......: 0.00%   0 out of 36601
    http_req_duration..............: avg=5.31ms min=831.22µs med=3.71ms max=102.52ms p(90)=10.43ms p(95)=14.28ms

From 524 down to 0.2 milliseconds. Dropping an index takes a millisecond; rebuilding it takes 10 seconds here, hours with real data volumes.

Save your progress? Sign up for free

Round 3: The Database Is Busy

Referee:

# on s1
V="valkey-cli -h s3 -a lab-valkey-123 --no-auth-warning"
$V config set maxmemory-policy noeviction >/dev/null
$V config set maxmemory 1mb >/dev/null
$V flushall >/dev/null
clear

Task: Everything has gotten slower, and now and then there are errors. Monitoring shows noticeably more queries on the databases. Target time: 5 min

Hint: Who is supposed to shield the databases from reads, and is it still doing so?

Solution Round 3

# on s1
cd ~/sd/tag16
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
journalctl -u kurz --since -1min --no-pager | tail -1
V="valkey-cli -h s3 -a lab-valkey-123 --no-auth-warning"
$V dbsize
$V info memory | grep -E '^used_memory_human|^maxmemory_human|^maxmemory_policy'

Expected:

    checks_failed......: 3.13%  1143 out of 36418
    ✗ anlegen 201
      ↳  98% — ✓ 590 / ✗ 11
    ✗ klick 302
      ↳  96% — ✓ 34685 / ✗ 1132
    http_req_duration..............: avg=27.25ms min=1.93ms med=24.36ms max=223.35ms p(90)=50.42ms p(95)=59.01ms
Nov 23 23:17:59 s1 kurz[58435]: 2026/11/23 23:17:59 cache set: OOM command not allowed when used memory > 'maxmemory'.
0
used_memory_human:1.60M
maxmemory_human:1.00M
maxmemory_policy:noeviction

The cache is empty and stays empty. Valkey already uses more than the permitted 1 MB without any data, and with noeviction it doesn’t evict anything but rejects every write. kurz does what it’s been supposed to do since Day 5: cache broken, so carry on with the database. Every redirect now goes to the replica, waiting times rise, and load shedding rejects whatever doesn’t get a slot within 20 ms. What does the configuration file say?

# on s1
ssh s3 "sudo grep ^maxmemory /etc/valkey/valkey.conf"

Expected:

maxmemory 256mb
maxmemory-policy allkeys-lru

The file is correct; someone changed the settings at runtime. A restart of Valkey would bring back the values but empty the cache. Better to reset them at runtime:

# on s1
$V config set maxmemory 256mb
$V config set maxmemory-policy allkeys-lru
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
$V dbsize

Expected:

OK
OK
    checks_failed......: 0.00%  2 out of 36326
    ✗ klick 302
      ↳  99% — ✓ 35723 / ✗ 2
    http_req_duration..............: avg=6.31ms min=862.16µs med=3.86ms max=132.35ms p(90)=11.96ms p(95)=18.36ms
1000

Two errors while filling, healthy after that. 1000 keys: exactly the codes from codes.txt.

Save your progress? Sign up for free

Round 4: The Customer Gets Turned Away

Referee:

# on s1
sudo sed -i 's/sc_gpc_rate(0,0) ge 1000/sc_gpc_rate(0,0) ge 50/' /etc/haproxy/haproxy.cfg
sudo systemctl reload haproxy
clear

Task: The customer abend has booked 200 requests per second and sends 20. Still, every second one fails. Target time: 4 min

Hint: Which status do they get, and who sends it?

Solution Round 4

# on s1
cd ~/sd/tag16
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
sudo tail -50000 /var/log/haproxy.log | awk '/POST \/api\/links/ {print $9}' | tail -600 | sort | uniq -c

Expected:

    checks_failed......: 0.82%  300 out of 36463
    ✗ klick 302
      ↳  99% — ✓ 35861 / ✗ 2
    ✗ anlegen 201
      ↳  50% — ✓ 302 / ✗ 298
    http_req_duration..............: avg=5.77ms min=280.29µs med=3.38ms max=136.58ms p(90)=10.89ms p(95)=17.4ms
    302 201
    298 429

Field 9 in the HAProxy log is the status. 298 times 429; kurz never saw these requests. What does the stick table count, and where is the limit?

# on s1
echo "show table web" | sudo socat stdio /run/haproxy/admin.sock
grep -n 'zu_viel' /etc/haproxy/haproxy.cfg | head -1

Expected:

# table: web, type: string, size:102400, used:1
0x7bc389637690: key=abend use=0 exp=29553 shard=0 gpc0_rate(5000)=46
21:    acl zu_viel sc_gpc_rate(0,0) ge 50

The customer gets 46 requests through in 5 seconds; the limit is at 50. What they booked is 200 per second, so 1000 in 5 seconds (Day 12). Check first, then reload:

# on s1
sudo sed -i 's/sc_gpc_rate(0,0) ge 50/sc_gpc_rate(0,0) ge 1000/' /etc/haproxy/haproxy.cfg
sudo haproxy -c -f /etc/haproxy/haproxy.cfg && sudo systemctl reload haproxy
sleep 10
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
sudo tail -50000 /var/log/haproxy.log | awk '/POST \/api\/links/ {print $9}' | tail -600 | sort | uniq -c

Expected:

    checks_failed......: 0.01%  6 out of 36185
    ✗ klick 302
      ↳  99% — ✓ 35579 / ✗ 6
    http_req_duration..............: avg=7.26ms min=863.29µs med=3.61ms max=150.33ms p(90)=14.8ms  p(95)=25.94ms
    600 201

The 10-second pause is no accident: on reload, HAProxy starts a new process, and the old one still answers ongoing connections with its old table. Anyone who measures immediately still sees a few 429s.

Save your progress? Sign up for free

Round 5: The Clicks Lag Behind

Referee:

# on s2
sudo mkdir -p /etc/systemd/system/zaehler.service.d
printf '[Service]\nEnvironment=ZAEHLER_BATCH=1\n' | sudo tee /etc/systemd/system/zaehler.service.d/vorsicht.conf >/dev/null
sudo systemctl daemon-reload && sudo systemctl restart zaehler
clear

Task: Redirects and link creation run without errors. But in the portal, the customer sees click counts that are minutes old, and the minutes keep adding up. Target time: 4 min

Hint: Day 10, the batch size measurement.

Solution Round 5

# on s1
cd ~/sd/tag16
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
nats consumer info KLICKS zaehler --json | jq .num_pending
sleep 10
nats consumer info KLICKS zaehler --json | jq .num_pending
ssh s2 "journalctl -u zaehler --no-pager -n 2; journalctl -u zaehler --no-pager -b | grep Batch | tail -1"

Expected:

    checks_failed......: 0.00%   0 out of 36588
    http_req_duration..............: avg=5.68ms min=832.21µs med=4.01ms max=188.75ms p(90)=11.3ms  p(95)=15.36ms
30848
28319
Nov 23 23:21:19 s2 zaehler[32690]: 2026/11/23 23:21:19 gezählt 6314
Nov 23 23:21:24 s2 zaehler[32690]: 2026/11/23 23:21:24 gezählt 7584
Nov 23 23:20:44 s2 zaehler[32690]: 2026/11/23 23:20:44 zaehler: Batch 1, Pause 0s

30,848 clicks are waiting. The counter manages 1270 in 5 seconds, so about 250 per second, against 1200 clicks per second. After the load test, the backlog shrinks, slowly: 2500 in 10 seconds. With batch 1, every message needs its own fetch, its own statement and its own acknowledgment, exactly the measurement from Day 10. Who set this?

# on s1
ssh s2 "systemctl cat zaehler | tail -3"

Expected:

# /etc/systemd/system/zaehler.service.d/vorsicht.conf
[Service]
Environment=ZAEHLER_BATCH=1
# on s1
ssh s2 "sudo rm -r /etc/systemd/system/zaehler.service.d && sudo systemctl daemon-reload && sudo systemctl restart zaehler"
sleep 3
nats consumer info KLICKS zaehler --json | jq .num_pending
ssh s2 "journalctl -u zaehler --no-pager -n 1"

Expected:

0
Nov 23 23:21:36 s2 zaehler[32884]: 2026/11/23 23:21:36 zaehler: Batch 500, Pause 0s

28,000 messages caught up in under 3 seconds. None got lost: the stream kept them until someone fetched them. That is the point of the queue from Day 10. A slow consumer makes the numbers stale, but not wrong.

Save your progress? Sign up for free

Scoring

The final measurement:

# on s1
cd ~/sd/tag16
echo "clear counters all" | sudo socat stdio /run/haproxy/admin.sock
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
nats consumer info KLICKS zaehler --json | jq .num_pending
echo "show stat" | sudo socat stdio /run/haproxy/admin.sock | awk -F, '$1 == "kurz" {print $2, $8, $44, $62}'

Expected:

    checks_failed......: 0.00%   0 out of 36602
    http_req_duration..............: avg=4.49ms min=907.88µs med=3.15ms max=44.12ms p(90)=8.71ms p(95)=11.83ms
0
s1 19061 0 49
s2 17541 0 48
BACKEND 36602 0 49
Points For
2 each round fixed within the target time
1 each round fixed, target time exceeded
0 round “solved” by switching off a component
+5 final measurement healthy: below 0.1% errors, p95 below 30 ms, backlog 0
Total Rating
15 Systems architect: you find the bottleneck before anyone reports it
10–14 Resilient: with measurements and statistics you’ll get anywhere
below 10 Redo the days behind the botched rounds

Challenge: The Double Round

In operations, a fault rarely comes alone. The referee sets up two faults at once:

Referee:

# on s1
ssh s2 "sudo systemctl stop postgresql@18-main"
V="valkey-cli -h s3 -a lab-valkey-123 --no-auth-warning"
$V config set maxmemory-policy noeviction >/dev/null
$V config set maxmemory 1mb >/dev/null
$V flushall >/dev/null
clear

Task: Get the system back to healthy. Then: is it really healthy? Target time: 8 min

Hint: The measurement only checks what a user sees. What doesn’t it see?

Solution

# on s1
cd ~/sd/tag16
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
journalctl -u kurz --since -40s --no-pager | grep -c 'cache set: OOM'

Expected:

    checks_failed......: 49.31% 17933 out of 36362
    ✗ anlegen 201
      ↳  48% — ✓ 293 / ✗ 307
    ✗ klick 302
      ↳  50% — ✓ 18136 / ✗ 17626
    http_req_duration..............: avg=47.01ms min=5.78ms med=28.42ms max=485.6ms  p(90)=101.74ms p(95)=109.79ms
10454

Every second request fails, far more than in Round 3 alone. Without cache and without replica, every redirect lands on the primary, after a failed attempt at the replica. The log only shows the cache. So fix that first:

# on s1
$V config set maxmemory 256mb >/dev/null
$V config set maxmemory-policy allkeys-lru >/dev/null
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'

Expected:

    checks_failed......: 0.81%  296 out of 36458
    ✗ anlegen 201
      ↳  99% — ✓ 598 / ✗ 3
    ✗ klick 302
      ↳  99% — ✓ 35564 / ✗ 293
    http_req_duration..............: avg=8.16ms min=895.39µs med=4.01ms max=133.39ms p(90)=17.21ms p(95)=30.67ms
    checks_failed......: 0.07%  27 out of 36383
    ✗ klick 302
      ↳  99% — ✓ 35755 / ✗ 27
    http_req_duration..............: avg=6.88ms min=789.87µs med=3.92ms max=169.01ms p(90)=13.25ms p(95)=21.33ms

0.07% errors and p95 21 ms: healthy by the rule. This is where half the participants stop. The cache catches almost all redirects and hides the fact that the replica is missing. Since Day 8, kurz quietly falls back to the primary and writes nothing to the log while doing so. The measurement the user doesn’t see is replication:

# on s1
ssh s3 "sudo -u postgres psql -c 'select client_addr, state, replay_lag from pg_stat_replication'"
ssh s3 "sudo -u postgres psql -c 'select slot_name, active, pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) as rueckstand from pg_replication_slots'"

Expected:

 client_addr | state | replay_lag
-------------+-------+------------
(0 rows)

 slot_name | active | rueckstand
-----------+--------+------------
 s2        | f      | 32 MB
(1 row)

No replica connected; the slot holds on to 32 MB of WAL until it comes back (Day 8). If the primary fails now, there is no server for the failover from Day 14.

# on s1
ssh s2 "sudo systemctl start postgresql@18-main"
sleep 3
ssh s3 "sudo -u postgres psql -c 'select client_addr, state, replay_lag from pg_stat_replication'"
k6 run -q wettkampf.js 2>&1 | grep -E 'checks_failed|✗|↳|http_req_duration\.'

Expected:

 client_addr  |   state   |   replay_lag
--------------+-----------+----------------
 172.16.0.228 | streaming | 00:00:00.00955
(1 row)

    checks_failed......: 0.00%   0 out of 36573
    http_req_duration..............: avg=5.22ms min=861.52µs med=3.55ms max=68.18ms p(90)=10.16ms p(95)=14.7ms

The lesson of the double round: every fallback that absorbs a failure (cache, replica, retry) needs its own signal in monitoring. Otherwise nobody sees that the reserve is already used up.

Save your progress? Sign up for free

Clean-up

All rounds end in a clean state. The load test links stay in the table, as on every day. The lab is now in the state that design.md from Day 15 describes, and stays that way for Appendix B.

Checkpoint

# on s1
PGPASSWORD=lab-kurz-123 psql -h s3 -U kurz -d kurz -tAc "select count(*) from pg_indexes where indexname = 'links_url_idx'"

Expected: 1

# on s1
ssh s2 "systemctl show kurz -p CPUQuotaPerSecUSec; systemctl show zaehler -p DropInPaths"

Expected:

CPUQuotaPerSecUSec=500ms
DropInPaths=
# on s1
valkey-cli -h s3 -a lab-valkey-123 --no-auth-warning config get maxmemory-policy
grep -c 'ge 1000' /etc/haproxy/haproxy.cfg

Expected:

maxmemory-policy
allkeys-lru
1

Interview note

  • “The system is slow. Where do you start?” With the measurement, not with a guess: what share fails, which percentile rises, which kind of request is affected? Then follow the request’s path: load balancer, instances, cache, database, queue. Every station has a number.
  • “How do you notice that a reserve is used up?” Every fallback needs its own metric: cache hit rate, connected replicas, retries per second, open circuit breakers. Error rate and latency alone stay green until the last reserve falls.
  • “What’s the difference between slow and wrong?” Round 5: the queue made the numbers stale, but not wrong, because nothing got lost. Round 2: without the dedupe index, a system without a timeout would have created duplicate links. Protect correctness first, then speed.

Enterprise note

  • In operations, an evening like this is called a game day: planned, with a referee, with measurement and a debrief. Every round produces an alert and a runbook entry.
  • All five rounds were changes made by a colleague, not a hardware defect. That is the most common cause of real incidents. Countermeasures are configuration in Git with review, drift detection (Ansible in check mode, systemctl cat against the desired state) and changes that can be rolled back with one command.
  • SRE teams phrase the question from the double round as “What would not alert us?”. The answer fills the next list of metrics: connected replicas, backlog size, cache hit rate, state of the circuit breakers.

Contents

More