Question presented to candidate:
"Design a distributed message queue, something like Kafka or SQS, that many services in our company can publish to and consume from. It has to survive machine failures without losing acknowledged messages and handle about a million messages a second at peak."
What a strong answer should cover:
Requirements and a worked capacity estimate (throughput, replication traffic, storage for the retention period, broker and partition counts)
The core data structure: topics split into partitions, each an append-only log of segment files on disk, with consumers reading by offset; keys hash to partitions so per-key order holds
Replication with a leader per partition, followers, the in-sync replica set (ISR), the high watermark, and the producer acks setting; how min.insync.replicas and unclean leader election trade availability for durability
Consumer groups: partition assignment, committed offsets stored durably, rebalancing, and the delivery semantics that follow (at-least-once by default)
A metadata/controller service built on consensus (as Kafka KRaft does) for leader election and partition placement, and the trade-offs at 10x scale (partition count, hot keys, rebalances, tiered storage)
Clarifying questions expected:
Do consumers need replay and many independent subscribers (a log), or per-message acknowledgement and retries (a queue)? Or both?
What ordering is required, and per what key?
What durability is required: can we lose acknowledged messages if a whole machine dies?
Code / implementation expected: Optional โ a simulation of one replicated partition showing how acks, ISR and leader election decide whether acknowledged messages survive; the example does that and also computes the capacity estimate.
system-design
case-study
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Engineers preparing for a senior system design round; you know what a server, a disk and a network are, and everything about logs and replication is defined as we go.
Difficulty: Hard
Verified with: Node 22.22, Python 3.12, Go 1.24 and Java 21 (all four print identical output). Kafka configuration defaults quoted are from the Kafka documentation and release notes, checked in October 2026.
How to read this doc: Every idea is explained in plain language first, then tagged with ๐ Interview term: so you also learn the exact words an interviewer expects. The capacity numbers and the failover runs come from the example program; the Verified section quotes its full output.
1. Why This Even Matters โ A Story First
Picture a town post office that never closes. Thousands of people drop off letters; dozens of delivery vans pick them up. Three rules ma
The solution is hidden so you can try first
17 min read ยท 16 sections
4
Read the code
One replicated partition: acks, ISR, high watermark, min.insync.replicas, unclean election, plus a capacity estimate