← Questions
Design a Kafka-like distributed message queue
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A system design interview question asked in Google's first round (coding) and at Databricks and Microsoft, last asked Sep 2025. It tests queues, replication and storage.
Design a durable, partitioned log, like Kafka. Producers append messages to topics; many consumer groups read the same topic, each at its own pace; acknowledged messages survive the failure of a broker.
Requirements
- Functional: create topics with partitions; produce messages (optionally with a key that picks the partition); consume from an offset; consumer groups that split a topic's partitions among their members and commit offsets; keep messages for a configured time or size.
- Non-functional: high throughput; ordering within a partition; no loss of acknowledged messages when a broker fails; consumers can replay from any retained offset; scale by adding brokers.
Clarifying questions
- What throughput and message size, and how long is data retained?
- Which delivery guarantee do consumers need: at most once, at least once, exactly once?
- Is ordering needed across a whole topic or only per key?
- How many consumer groups per topic, and do some read far behind the head?
- One data center or several?
What a strong answer covers
- A partition as an append-only log split into segment files with an offset index; sequential disk writes and the page cache for throughput.
- Replication: a leader per partition, followers that fetch from it, an in-sync replica set, and acknowledgement levels; what is lost under each setting.
- Leader election and cluster metadata through a controller backed by a consensus system.
- Consumer groups: partition assignment, rebalancing when members join or leave, committed offsets stored durably.
- Producer batching and compression; idempotent producers and transactions for exactly-once processing.
- Retention and compaction, adding brokers and moving partitions, and monitoring consumer lag.
Follow-ups
- A broker that leads many partitions dies. What happens step by step?
- One partition is much hotter than the others.
- A consumer group falls a day behind. How does that affect the brokers?
- Replicate a topic to another region for disaster recovery.
Where it's asked
- Google · First round: coding · Last asked Sep 202545 min · Coding in a Google Doc, no syntax highlighting or autocomplete · No AI
- Databricks
- Microsoft
What it tests
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. New accounts get 5 credits: each one unlocks a question for good.
What the labs asked this week
A weekly email of what OpenAI, Anthropic and the other top AI labs asked engineers, round by round.
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing


