System Design AI

Message Queues: Follow-Up Questions Interviewers Ask (and How to Answer)

When a candidate brings up a message queue, interviewers see an opening to explore how you think about asynchronous pipelines. Queues sit at the heart of many high-scale services, so the next questions dig into durability, ordering, latency, and operational complexity. The goal is to gauge whether you can pick the right queue technology, size it for traffic, and anticipate failure modes.

A senior-level answer will name the right AWS service, give a ballpark capacity, and explain the main trade-offs. A staff-level answer will also quantify cost, discuss monitoring, and describe how the design evolves as traffic grows.

How do you guarantee message ordering?

I would choose a FIFO queue when strict ordering matters, such as processing financial transactions. With Amazon SQS FIFO, each message group ID preserves order, and the service guarantees exactly-once delivery. If the workload can tolerate partial ordering, a standard queue is cheaper and can scale to higher throughput. For example, I’d use a FIFO queue for a payment pipeline that processes ~5,000 transactions per second, ensuring each account’s events stay in order.

What is the typical latency you can expect?

Latency depends on the queue type and region. In practice, a managed queue like SQS typically adds a few tens of ms for a single hop; I would measure it rather than quote a figure, and expect a FIFO queue to cost a few more ms due to stricter ordering. If the application needs sub-10 ms latency, I’d benchmark a streaming log such as Kafka on Amazon MSK, which writes to disk but lets consumers fetch continuously, and check whether the delay I measure stays under 10 ms under moderate load.

How do you size the queue for peak traffic?

First, I estimate the peak request rate. Suppose the service receives 200 k requests per second during a flash sale. If each request generates one message, the queue must ingest 200 k messages per second. I’d provision multiple partitions (or shards) to spread the load—I’d assume about 1 KB per message and budget a conservative 1 MB/s per partition, so I’d start with at least 200 partitions, then monitor and add more as needed. For SQS, a standard queue scales automatically, so the sizing work moves to the consumers: I’d scale them on queue depth and the age of the oldest message, and keep the dead-letter queue for messages that keep failing.

How do you handle message duplication?

Even “exactly-once” services can occasionally deliver duplicates under rare failure scenarios. My approach is to make the consumer idempotent: store a hash of the message ID and reject repeats. For a payment system, I’d write the transaction ID to a DynamoDB table with a conditional write; the write succeeds only once, guaranteeing no double charge. This adds a small overhead—roughly a few milliseconds per message—but protects against costly duplication bugs.

What happens if a consumer crashes while processing a message?

If a consumer crashes after pulling a message but before acknowledging it, the message becomes visible again after the visibility timeout expires. I set the timeout slightly longer than the typical processing time—say 30 seconds for a batch job that usually finishes in 10 seconds. To avoid long-running tasks holding the queue, I break large jobs into smaller chunks, each idempotent, and use a retry back-off strategy.

How do you ensure durability of messages?

Durability is handled by the underlying storage. SQS stores messages across multiple AZs automatically, giving “at-least-once” durability. For Kafka, I would configure a replication factor of three and enable log-segment retention for at least 24 hours, ensuring that a broker failure does not lose data. In a critical system, I’d also mirror the stream to an S3 bucket using a connector, providing an immutable backup.

How do you monitor queue health?

I instrument three key metrics: queue depth, consumer lag, and error rate. Queue depth shows backlog; if it exceeds a threshold—say 10 % of the expected processing capacity—I trigger an alarm. Consumer lag (difference between latest offset and consumer offset) tells me if consumers are falling behind. I also track the number of messages sent to the dead-letter queue; a sudden spike indicates a processing problem. All metrics feed into a CloudWatch dashboard for rapid visibility.

What are the cost implications of your design?

Costs scale with throughput and storage. For SQS standard, you pay per request (about $0.40 per million at list price) and for data transferred out, not for storage. At 200 k requests per second, that’s about 17 billion requests per day, costing roughly $7,000 per day for the request fee alone. Adding retention of 24 hours adds nothing, because SQS does not bill for stored messages. Kafka on MSK has a higher base cost (instances and storage) but can be cheaper at very high throughput because you amortize the per-request cost across many messages. I’d run a cost model to pick the cheaper option for the expected load.

How would you evolve the system as traffic grows?

I would start with a modest number of partitions and enable auto-scaling for the consumer group. As traffic climbs, I’d increase partition count to avoid hot spots and add more consumer instances to the consumer group. If latency becomes a concern, I might introduce a tiered architecture: a fast-path in-memory queue for latency-sensitive requests and a durable queue for bulk processing. Periodic capacity testing ensures the scaling plan stays valid.

How to practice this

  1. Review the worked design on message queues in the System Design AI library. It walks through a full end-to-end pipeline with diagrams and notes.
  2. Use the practice brief to draw your own queue architecture on the canvas, focusing on ordering, latency, and failure handling.
  3. Run through the nine follow-up questions aloud, timing yourself to keep answers concise and data-driven.

Questions people ask

What is the difference between a standard and FIFO queue?

Standard queues give high throughput and at-least-once delivery but no ordering guarantee. FIFO queues guarantee exactly-once delivery and preserve order per message group, at the cost of lower throughput.

Can I mix multiple queue types in one system?

Yes. Use FIFO for critical ordered flows like payments and standard queues for bulk, unordered processing such as log aggregation. This balances cost and performance.

How do dead-letter queues help?

Dead-letter queues capture messages that repeatedly fail processing, preventing them from blocking the main queue. You can later analyze these messages to fix bugs or adjust retry policies.

When should I consider moving from a cloud-managed queue to a self-hosted broker?

When you need fine-grained control over partitioning, replication, or when the per-message cost of a managed service becomes prohibitive at very high volumes (hundreds of millions per day).