Appendix C: Interview problems
Five problems from system design interviews, each played through the way you would solve it at the whiteboard in 45 minutes. This time with a cluster behind you: interviewers today rarely ask “How does that scale?”, but “How does that run on Kubernetes, and what happens when a zone fails?”. Behind almost every building block there is a day in this course on which you built it, measured it and broke it. You may say so. “I measured that the proxy costs 400 millicores per Pod” beats “a mesh has some overhead”.
The process in four steps
| Step | Time | What you do |
|---|---|---|
| 1. Requirements | 5 min | Clarifying questions: what exactly, for whom, how much, what not? Write down goals, SLO and non-goals |
| 2. Estimation | 5 min | Requests per second (average and peak), CPU, storage, reserve for the loss of a zone |
| 3. Design | 15 min | The simplest architecture that handles the numbers. Data flow, building blocks, Kubernetes form |
| 4. Deep dive | 20 min | Bottlenecks, failures, trade-offs, operations. This is where the interview is decided |
The calculations are given as awk so you can recompute
them on s1. The figures in them come from the course: 4.5 ms CPU per
request for the whole stack, of which 0.9 ms for kurz (Day
14), 96 clicks per second per zaehler Pod (Day 10), about
46 bytes per message in the stream (Day 14). In the interview you
calculate in your head and round boldly: a day has roughly 100,000
seconds.
C.1 A URL shortener on Kubernetes
Problem: “Design a URL shortener with click statistics, operated on Kubernetes in three zones.” The problem of this course, now in 45 minutes.
Clarifying questions and assumptions:
- 50 million redirects per day, 5 million new links per month, links stay for 5 years.
- SLO: p95 of redirects under 100 ms, error rate under 0.1 %, even when a zone is missing.
- Clicks may be counted seconds to minutes late, but not twice.
Estimation:
# on s1
# Load, CPU with and without zone reserve, storage for stream and database
awk 'BEGIN { t = 50e6; m = t / 86400; s = 3 * m
printf "Weiterleitungen: %.0f/s im Mittel, %.0f/s Spitze\n", m, s
printf "CPU zur Spitze: %.1f Kerne (4,5 ms je Anfrage), davon kurz %.1f\n", s * 0.0045, s * 0.0009
printf "mit Zonenreserve: %.1f Kerne (3 Zonen, eine darf fehlen)\n", s * 0.0045 * 3 / 2
printf "Stream 24 h: %.1f GB (46 Byte je Klick)\n", t * 46 / 1e9
printf "Links 5 Jahre: %.0f GB (5 Mio. im Monat, 180 Byte)\n", 5e6 * 12 * 5 * 180 / 1e9 }'Expected:
Weiterleitungen: 579/s im Mittel, 1736/s Spitze
CPU zur Spitze: 7.8 Kerne (4,5 ms je Anfrage), davon kurz 1.6
mit Zonenreserve: 11.7 Kerne (3 Zonen, eine darf fehlen)
Stream 24 h: 2.3 GB (46 Byte je Klick)
Links 5 Jahre: 54 GB (5 Mio. im Monat, 180 Byte)
Redirects 579/s on average and 1736/s at peak; 7.8 cores at peak, of
which 1.6 for kurz; 11.7 cores with zone reserve; 2.3 GB of
stream for 24 hours; 54 GB of links in 5 years.
Design:
Client → LoadBalancer → Gateway (Envoy, ≥ 2 Pods in different zones)
limit per customer, circuit breaker, retry only on connection errors, deadline per attempt
→ kurz (Deployment, ≥ 1 Pod per zone, autoscaler on CPU, PDB)
├─ GET /{code}: cache cluster → replicas (db-ro) → primary only as fallback
│ click asynchronously into the stream
└─ POST /api/links: pooler → primary
→ stream (3 replicas, one per zone) → zaehler (scales by backlog, 0–N) → database
Database: operator with primary + 2 replicas, one instance per zone, failover by the operator
Deep dive the interviewer wants to hear:
- The CPU does not go to the app. Of 4.5 ms CPU per
request,
kurzneeds 0.9 ms. Gateway and mesh together cost more than twice as much as the application (Day 14). 1.6 cores for the app, but almost 12 cores for the stack with zone reserve. Whoever estimates only the app is off by a factor of five. - Capacity means: with one zone less. In the lab, three zones carried 1000 requests per second within the SLO, two zones only 400 (p95 47 ms); at 700 there were 3.6 % errors (Day 14). The number that belongs in the design document is the smaller one.
- Never count clicks synchronously. Synchronously
into the database,
kurzmanaged 453 instead of 994 redirects per second, p95 1.24 s instead of 54 ms (Day 8). The stream needs 2.3 GB for 24 hours. The volume must be sized for that, otherwise JetStream accepts nothing more, and a publish without acknowledgment does not notice (Appendix B). - Cache before everything else. p95 131 → 85 ms, database load 90 % lower at 97.5 % hits (Day 5). And the price: an empty cache under full load does not fill up by itself if requests abort before the write (Appendix B).
- Failures: a Pod crash without retry costs 287
errors at 800 per second, with retry on connection errors 16 (Day 4). A
rollout without a
preStoppause costs up to 47 errors, with one only zero or one. - Storage is not a problem. 54 GB in 5 years fit on one instance with replicas. Sharding would be one box too many here.
C.2 A rate limiter in the API gateway
Problem: “Design rate limiting for an API gateway in front of many services, with limits per customer, 20,000 requests per second at peak.”
Clarifying questions and assumptions:
- Limits per API key (header), e.g. 50 per second, shared across all gateway Pods.
- A few requests too many during faults are better than locking out legitimate customers.
- The gateway runs in the cluster and scales horizontally.
Estimation:
# on s1
# Gateway CPU, number of Pods, what a local limit would mean, concurrent checks
awk 'BEGIN { r = 20000; k = r / 1000 * 1.05; p = int(k / 2 + 0.999)
printf "Envoy-CPU: %.0f Kerne (1,05 Kerne je 1000/s, Tag 14)\n", k
printf "Envoy-Pods à 2 Kerne: %d, lokales Limit 50/s ließe %d/s je Kunde durch\n", p, 50 * p
printf "Prüfungen gleichzeitig: %.0f bei 2 ms, %.0f bei 200 ms Frist\n", r * 0.002, r * 0.2 }'Expected:
Envoy-CPU: 21 Kerne (1,05 Kerne je 1000/s, Tag 14)
Envoy-Pods à 2 Kerne: 11, lokales Limit 50/s ließe 550/s je Kunde durch
Prüfungen gleichzeitig: 40 bei 2 ms, 4000 bei 200 ms Frist
Envoy needs 21 cores; with 2 cores per Pod that is 11 Pods, and a local limit of 50/s would let 550/s per customer through; 40 concurrent checks at 2 ms, 4000 at a 200 ms deadline.
Design:
Client → gateway Pods (Envoy) ──► rate limit service (stateless, ≥ 2 Pods) ──► counter store (Valkey)
│ over the limit: 429
│ store gone or too slow: let through, counter failure_mode_allowed, alert
└→ backend, behind it a circuit breaker against overload
Deep dive:
- Local or global: a local limit counts per gateway Pod. With two Envoys and a limit of 600 per second, 1229 got through (Day 11). With 11 Pods, a limit of 50 would become one of 550. Local is fine as rough protection for the backend; customer contracts need global.
- The deadline decides: with the default deadline of 20 ms for the rate limit service, 58 % of the requests went through unchecked. Ten customers with 100 per second each reached 857 instead of 500 per second together. With 200 ms it was 509 and 1.3 % unchecked, but p95 of the redirects rose from 158 to 211 ms (Day 11). Little’s Law says what that means at 20,000 per second: 40 open checks normally, 4000 when the store hangs and every request sits out the deadline.
- Fail open, but visibly: without the rate limit
service, Envoy let 10,000 out of 10,000 requests through (Day 11).
Without its store as well, and every request waited out the 200 ms: p95
36 → 218 ms (Appendix B). Failing open is right; failing silently is
not. The alert belongs on
failure_mode_allowed. - What counts: only requests with a key. Without the header, a limit per header value does not apply (Day 11). Anonymous users need a rule of their own, for example per source IP, and the gateway often does not see it behind SNAT (Day 3).
- A rate limit is not load protection. It protects
against individual customers. The circuit breaker protects against
overload as a whole: with two small Pods at 1000 per second, the
rejections came in 36 ms, and p95 of the remaining redirects dropped
from 572 to 343 ms (Day 11). Better a fast
503than a slow302.
C.3 An event pipeline
Problem: “Design the processing of usage events: services report events, a statistic counts them. 5000 events per second at peak.”
Clarifying questions and assumptions:
- A delay of up to a few minutes is allowed; events must not be counted twice and should not get lost.
- Almost no load at night, peaks during the day. A 10-minute outage of the processing must be caught up afterwards.
Estimation:
# on s1
# Workers for the peak, backlog and draining it after an outage, storage in the stream
awk 'BEGIN { r = 5000; je = 96
printf "Worker für die Spitze: %.0f (96/s je Pod, Tag 10)\n", r / je
printf "Rückstau nach 10 min Ausfall: %.0f, Abbau mit 80 Pods: %.0f s\n", r * 600, r * 600 / (80 * je - r)
printf "Stream 24 h: %.1f GB (46 Byte je Ereignis)\n", r * 86400 * 46 / 1e9 }'Expected:
Worker für die Spitze: 52 (96/s je Pod, Tag 10)
Rückstau nach 10 min Ausfall: 3000000, Abbau mit 80 Pods: 1119 s
Stream 24 h: 19.9 GB (46 Byte je Ereignis)
52 workers for the peak; a backlog of 3,000,000 after a 10-minute outage, drained by 80 Pods in 1119 s; 19.9 GB of stream for 24 hours.
Design:
Services → publish with acknowledgment and Msg-ID → stream (3 replicas, time-based limit, 24 h)
→ workers (durable consumer, batch, explicit ack) → upsert into the statistics
+ dedupe table in the same statement
Autoscaler: Pods = ⌈backlog ÷ threshold⌉, 0 to N, brake on scale-up, fallback on metric errors
Deep dive:
- Scale on the right signal. An HPA on CPU saw a worker at 2 % utilization while 60,000 messages were waiting (Day 9). KEDA on backlog went from 1 to 10 Pods in 55 seconds and to zero when there was nothing to do, and back up in 6 seconds (Day 10). The threshold is the most important number: with 50,000 instead of 500, it stayed at one Pod (Appendix B).
- More workers are not more throughput. 10 Pods
managed 299 events per second, because the upserts locked each other
(deadlocks). A sorted lock order (
ORDER BY) turned that into 960 (Day 10). With 15 Pods it dropped again to 670: the consumer’s limit of unacknowledged messages was full. So 52 workers need partitioned subjects or several consumers, not just more Pods. - Exactly once means: at least once plus dedupe. Stream 6001 = database 6001 after a run starting from zero Pods (Day 10). The dedupe table is in the same statement as the counting (Day 8).
- Not lost means: publish with acknowledgment. When the stream leader changed, core publish silently lost 48 out of 59,621 clicks. With asynchronous publish, a deadline and an error handler, only 5 out of 59,720 were missing, and each of them was among the 19 reported (Day 8). Whoever wants to resend them needs an outbox, not a retry in the handler: that blocked when the queue was full, p95 15 s.
- Limits on time, not on bytes with
discard: new. A full stream accepts nothing more, and without acknowledgment nobody notices (Appendix B). 20 GB per day belong in the volume planning, with an alert at 80 %. - Catching up takes time. A backlog of 3 million events takes 80 Pods almost 19 minutes, because the ongoing load keeps arriving. The database must be able to write that, too.
C.4 A service across three zones
Problem: “A service with a database is to survive the failure of a data center. SLO 99.9 % per month, 1000 requests per second. How do you distribute it on Kubernetes?”
Clarifying questions and assumptions:
- Three zones in one region, low latency between them. Reads dominate, 10 % writes.
- Writes may fail briefly during a zone outage; reads should keep working.
- Must an unplanned failover lose no data at all? That is the clarifying question. Assumption here: seconds of data are acceptable, availability comes first.
Estimation:
# on s1
# Error budget, cost of a zone outage, capacity per zone
awk 'BEGIN { r = 1000; monat = 30 * 86400
printf "Fehlerbudget 99,9 %%: %.0f min oder %.0f Anfragen im Monat\n", monat * 0.001 / 60, r * monat * 0.001
printf "Zonenausfall wie Tag 13: ~%.0f Fehler (910 bei 300/s hochgerechnet)\n", 910 * r / 300
printf "Kapazität: %.0f/s je Zone nötig, damit zwei Zonen %d/s tragen\n", r / 2, r }'Expected:
Fehlerbudget 99,9 %: 43 min oder 2592000 Anfragen im Monat
Zonenausfall wie Tag 13: ~3033 Fehler (910 bei 300/s hochgerechnet)
Kapazität: 500/s je Zone nötig, damit zwei Zonen 1000/s tragen
Error budget at 99.9 %: 43 minutes or 2,592,000 requests per month; a zone outage like on Day 13 costs ~3033 errors (910 at 300/s, scaled up); each zone needs 500/s so that two zones carry 1000/s.
Design:
Zone a Zone b Zone c
Gateway Pod Gateway Pod Gateway Pod
App Pod(s) App Pod(s) App Pod(s) topology spread, maxSkew 1,
nodeTaintsPolicy Honor, PDB
DB instance (primary) DB instance (replica) DB instance (replica)
Cache primary/replica … … primaries and replicas crossed
Control plane (1/3) Control plane (1/3) Control plane (1/3)
Deep dive:
- Readiness checks its own Pod. In the lab, a zone outage with the primary took the healthy Pods of the other zones with it, because their readiness checked cache and database: 42 % errors in the first window. Without dependencies in the probe it was 6 %, a third of the errors overall (Day 13).
- Failover has a rhythm. Kubernetes declared the node
NotReadyafter 51 seconds; after 62 seconds a new primary was there (Day 13). A window of about a minute without writes remains. Whoever does not want that needs synchronous replication and pays with write latency, and with hangs when the replicas are missing (Day 6). - The budget calculation: a zone outage costs about 3000 out of 2.6 million allowed errors per month. The budget can take that. The planned changes are much more expensive: a switchover under 800 per second cost 7 % of a minute’s requests in the lab, almost all of them on writes (Appendix B). That is why switchovers belong in low-load windows and before every drain.
- Capacity: three zones must be big enough that two carry the load. In the lab, two zones managed 400 instead of 1000 per second (Day 14). For 1000 within the SLO, each zone would need more than double.
- Look at state and control first. In the lab, the
k3s server, CoreDNS, the Linkerd control plane and KEDA were in one zone
(Day 13). “Pods in three zones” is not zone-redundant as long as the
control plane sits in one. The same goes for volumes on the node:
local-pathbinds a Pod to its zone; the replacement staysPending. - PDBs only protect against planned disruptions.
During the drain they slowed things down correctly; against the zone
outage they did nothing. A PDB with
minAvailableequal to the Pod count prevents any maintenance (Appendix B).
C.5 A service with load peaks
Problem: “A ticket shop normally has 300 requests per second. When a presale starts, there are 3000 within 30 seconds. How do you set up autoscaling?”
Clarifying questions and assumptions:
- The start of the presale is known days in advance. Other peaks come unannounced.
- Better a fast rejection (“please try later”) than waiting for minutes.
- The cluster has fixed nodes; new nodes take minutes.
Estimation:
# on s1
# CPU before and during the peak, requests missing during the HPA's reaction time
awk 'BEGIN { vor = 300; nach = 3000; reakt = 98
printf "Kerne vorher/nachher: %.1f / %.1f (4,5 ms je Anfrage)\n", vor * 0.0045, nach * 0.0045
printf "Anfragen über der alten Kapazität, bis der HPA fertig ist: %.0f (%d s, Tag 9)\n", (nach - vor) * reakt, reakt }'Expected:
Kerne vorher/nachher: 1.3 / 13.5 (4,5 ms je Anfrage)
Anfragen über der alten Kapazität, bis der HPA fertig ist: 264600 (98 s, Tag 9)
1.3 cores before, 13.5 cores during the peak; 264,600 requests above the old capacity until the HPA is done (98 s, Day 9).
Design:
known peak: cron trigger raises the minimum before the start (KEDA cron + cpu)
unknown peak: HPA on CPU, target relative to the request, fast scale-up, slow scale-down
in the gap: gateway: circuit breaker and waiting-room limit → fast 503/429 instead of a jam
underneath: enough free node capacity, otherwise new Pods stay Pending
Deep dive:
- The HPA is too slow for a peak. On a jump from 0 to 1000 per second, the first measurement came after 49 seconds, and all 8 Pods were ready after 98 seconds. Until then p95 ran at 676 ms (Day 9). At 3000 per second, that is over 260,000 requests that exceed the old capacity. Nobody can buffer that, so scale beforehand or reject.
- Plan known peaks. A cron trigger in KEDA set 4 Pods right on time for the window and only went back to 2 after the stabilization period (Day 10). That is the cheapest answer to a known presale.
- More Pods only help with free nodes. At 1200 per
second, p95 with 6 Pods was worse than with 2 (98 versus 71 ms), because
the nodes were the bottleneck (Day 9). 13.5 cores must be there as free
capacity, not just as
maxReplicas. - Requests and limits decide whether the HPA can calculate. With request = limit, utilization can never rise above 100 %, and a target of 200 % is never reached (Day 9). Without a CPU request in one container, such as the mesh proxy, it does not calculate at all (Day 13).
- Rejecting is a feature. With a circuit breaker, rejections came in 36 ms, and p95 of the remaining redirects dropped from 572 to 343 ms (Day 11). For a presale, a waiting room with a limit per user is more honest than a shop that becomes slow for everyone.
- Scale down slowly. The HPA only shrank 4.5 minutes after the load ended (Day 9). For peaks that come in waves, that is right: Pods that are needed again soon cost less than a second scale-up.
What goes down well in every interview
- Numbers first, for the platform too. Whoever estimates only the app forgets gateway, mesh, cache, database and stream. In the lab, the app was a fifth of the CPU (Day 14).
- Capacity with one zone less. The number for the design document is the one that is still within the SLO when a zone fails, not the peak that barely works.
- Every trade-off with its price. A mesh means mTLS and better load balancing, but costs p95 and 400 millicores per Pod (Day 12). Asynchronous means late. A cache means a cold start. Synchronous replication means hanging without a replica. Autoscaling means reaction time.
- Play through failures before the interviewer asks: “What happens when a zone fails?” You measured it on Day 13, with events down to the second.
- Mention configuration drift. Almost every fault in the competition and in the final exam was a change to the running system, not a defect (Day 15). GitOps and alerts on silent signals belong in every design.
- Measure instead of claim. Say what you measured, and add that it was your lab: three small VMs; numbers change with the hardware, the order of magnitude and the direction do not.