Design a distributed message queue system where multiple publishers send messages to named topics and multiple subscribers consume those messages. The system must provide an at-most-once delivery guarantee: a message may be lost under certain failure conditions, but it must never be delivered more than once to a given subscriber. Think of systems like Apache Kafka, Google Cloud Pub/Sub, or Amazon SNS/SQS.
The core engineering challenges are partitioning topics for write throughput, coordinating consumer groups for parallel consumption, enforcing at-most-once semantics (which fundamentally changes how producers, brokers, and consumers handle acknowledgments), managing backpressure from slow consumers, and providing operational visibility into lag, drop rates, and throughput. You will need to reason about delivery semantics, partition strategies, consumer offset management, and failure handling.
Based on real interview experiences at Anchorage Digital and Amazon, these are the areas interviewers probe most deeply:
The at-most-once guarantee is the defining constraint of this design. Interviewers want to see that you understand how it shapes every layer: producer acknowledgments, broker replication, and consumer offset management. Getting this wrong (accidentally building at-least-once) is the most common mistake.
Hints to consider:
Scaling both writes and reads requires partitioning topics and assigning partitions to consumers within a group. Interviewers evaluate your understanding of partition-key routing, rebalancing, and the interaction between partition count and parallelism.
Hints to consider:
At-most-once systems cannot retry, so slow consumers risk unbounded queue growth or message drops. Interviewers expect explicit backpressure and drop policies.
Hints to consider:
Messages must be stored durably on brokers (subject to the at-most-once caveat) and retained for a configurable period. Interviewers assess your storage model and lifecycle management.
Hints to consider:
In production, many teams share the same message queue cluster. Interviewers look for isolation, quotas, and observability.
Hints to consider:
Confirm the delivery guarantee is at-most-once, not at-least-once. Ask about expected message throughput (messages per second), average message size, number of topics and consumer groups, and retention period. Clarify whether ordering is required globally or per-partition. Determine if multi-tenancy is in scope and whether the system must run in a single region or across multiple regions.
Sketch the main components: producer clients, a set of broker nodes that own topic partitions, a coordination service (ZooKeeper or equivalent) for metadata and consumer group management, consumer clients organized into consumer groups, and a monitoring stack. Show the publish flow: producer selects a partition via key hashing, sends the message to the partition leader with acks=1, and the broker appends to the log. Show the consume flow: consumer fetches messages from its assigned partitions, commits the offset before processing, and processes the message.
Walk through a message lifecycle. A producer publishes a message to topic T, partition P. The broker leader receives the write, appends it to the segment file, and acknowledges the producer without waiting for follower replication. If the leader crashes before replication, the message is lost -- acceptable under at-most-once. A consumer in group G is assigned partition P. It fetches the next batch of messages starting from its committed offset. Before processing, it commits the new offset. If the consumer crashes after committing but before processing, those messages are skipped -- also acceptable. Explain how this differs from at-least-once (where you would commit after processing, risking redelivery on crash).
Cover consumer group rebalancing: when a consumer joins or leaves, the coordinator triggers a rebalance, reassigning partitions; during rebalance, consumption pauses briefly. Discuss backpressure: bounded buffers with drop policies, lag monitoring, and per-tenant rate limits. Address retention: time-based and size-based segment deletion, with optional compaction for keyed topics. Mention operational tooling: dashboards for per-topic throughput, consumer lag alerts, and self-service topic provisioning. Discuss scaling: add broker nodes and redistribute partitions, increase partition count for hot topics, and use rack-aware replica placement for fault tolerance.