The interview question

Build a queue that lets workers process jobs despite crashes and intermittent network failures.

Distinguish delivery from processing and make retries safe at the business-effect boundary.

Quick answer

A durable message queue decouples producers from workers by storing jobs until they can be processed. Define when enqueue and consumer acknowledgments become durable, then make repeated processing safe. At-least-once delivery needs idempotency at the business-effect boundary, not just a unique message ID.

01. Define the acknowledgment contract

A producer receives success only after the queue has durably accepted the job under the chosen replication policy. A consumer acknowledgment means the queue may stop redelivering that message. Neither acknowledgment alone proves that an external business effect happened exactly once.

Start with at-least-once delivery, bounded retention, a visibility timeout or lease, and durable message IDs. Define whether ordering is global, per key, or absent. Per-account ordering is often more practical than forcing unrelated jobs through one ordered stream.

02. Trace the crash window

Durable enqueue
Worker lease
Effect & acknowledgment

A worker receives job J, writes its result to a database, then crashes before acknowledging. The queue redelivers J. If repeating the database write changes the result twice, the system is incorrect even though the queue behaved as promised.

Store the job ID and business update in the same transaction when they share a database. For external effects, use the destination’s idempotency support or a reconciliation protocol. A separate “processed” flag written before or after the effect leaves another crash window unless the operations are coordinated.

03. Budget throughput and backlog

Suppose arrivals average 2,000 jobs per second and workers complete 2,500. A backlog of one million jobs drains at a net 500 per second, taking about 2,000 seconds, or 33 minutes, under stable conditions. Dividing by total worker capacity would underestimate drain time because new jobs keep arriving.

Monitor oldest-job age, ready backlog, in-flight jobs, processing duration, and redelivery rates. Isolate tenants or job classes so one slow dependency cannot block all useful work. Scale consumers only as far as downstream capacity permits.

04. Handle poison jobs and lease loss

Retry transient errors with bounded backoff. Move repeatedly failing jobs to a reviewable dead-letter path with original payload and error context. A replay is a new operational action that still needs deduplication and rate control.

A lease can expire while a worker is paused but alive. Another worker may start the same job; heartbeats reduce this risk but do not eliminate it. Follow-up: long tasks can checkpoint, extend leases, and use fencing or idempotent outputs. Explicitly state what happens to work after retention expires.

Practice the follow-up

Self-review

Explain why acknowledging after a successful external request can still result in duplicate effects.

Connect this to job scheduling.

Size recovery capacity, including retries

At 2,000 new jobs/second, a ten-minute worker outage creates 1.2 million jobs. If recovered workers sustain 2,500 successful new-job completions/second while arrivals continue, net drain is 500/second and recovery takes 2,400 seconds: 40 minutes.

Now change the assumption: 2,500 is attempt capacity, and each completed job consumes an average of 1.2 attempts, including retries. Useful capacity is 2,500/1.2 ≈ 2,083.3 jobs/second. Net drain is only 83.3/second, so recovery takes about four hours. If attempts per job reach 1.25, all capacity is consumed by ongoing arrivals and the backlog never drains under these steady assumptions.

Separate attempt throughput from useful completions in dashboards. Admission control, retry budgets and downstream limits matter more than adding queue partitions when the dependency is saturated. Use the system-design sizing calculator for the initial traffic estimate, then add this backlog and retry model. Validate sustained rates with realistic payloads, failure rates and downstream quotas.

Original worked follow-up, reviewed October 7, 2026. Reference: Amazon SQS: at-least-once delivery.

Sources & further reading

Amazon SQS: at-least-once delivery. The interview scenario, calculations, and proposed design choices are illustrative.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.