System Design Interview Questions: Dead Letter Queue Patterns

Reviewed by Mark Dickie · Last updated

9 questions on this page you can answer and see marked on the spot. Go to the first one

A dead letter queue (DLQ) is a separate queue where a message broker routes messages that cannot be processed after a configured number of delivery attempts. For a system design interview, you should know the retry-and-DLQ lifecycle: a consumer retries a failed message up to N times, then the broker moves it to the DLQ so the main queue stays unblocked. Interviewers want you to explain when a DLQ is preferable to in-place retry, how backoff and max-attempt settings interact, and what happens to poison messages that would otherwise block a queue indefinitely.

What should I know about dead letter queues for a system design interview?

A DLQ is one of the core reliability patterns in distributed messaging, and interviewers test whether you can place it correctly among retry, idempotency, and circuit-breaker strategies. You should be able to describe the lifecycle of a failed message, the role of exponential backoff, and the operational work of draining a DLQ once it fills.

ConceptWhat it meansWhy an interviewer asks
Max receive countThe number of delivery attempts before a message is moved to the DLQTests whether you set a real bound instead of infinite retry
Redrive policyThe rules that move messages from a source queue to the DLQChecks you understand the broker-specific mechanism (SQS, RabbitMQ, Kafka)
Poison messageA message that always fails, often due to malformed contentTests whether you isolate bad messages from the main processing path
Backoff strategyIncreasing the wait between retries (fixed or exponential)Checks you avoid thundering-herd load on downstream dependencies
  1. State the failure mode you are protecting against before proposing a DLQ — infinite retry, poison messages, or transient downstream outages.
  2. Set a max receive count that is high enough to ride out a short blip but low enough that poison messages do not stall a worker for minutes.
  3. Apply exponential backoff between retries so a downstream service outage does not get hammered with immediate re-deliveries.
  4. Decide whether DLQ messages get inspected by a human, auto-reprocessed after a fix, or discarded — and say which alert fires when the DLQ depth grows.
  5. Make the consumer idempotent, because retries and redrive both deliver the same message more than once.

How do DLQs differ across common message brokers?

In Amazon SQS a redrive policy moves messages to a configured DLQ after maxReceiveCount attempts. RabbitMQ uses dead-letter exchanges with x-dead-letter-exchange arguments, and the routing key can change on dead-lettering. Kafka does not have a native DLQ; the common pattern is for the consumer to catch the exception and publish the failed record to a separate error topic. Knowing these differences lets you explain the tradeoffs when an interviewer asks you to pick a broker for a given reliability requirement.

Key facts

  • Tarmac's System Design interview questions cover 22 questions at difficulty 1–5 of 5.
  • Tarmac tracked 2,173 job postings asking for System Design in November 2026.
  • Roles asking for System Design advertise a median base salary of £86,000, across 642 job postings as of November 2026.
  • Tarmac last reviewed these System Design interview questions on 13 October 2026.

At a glance

Questions22
Difficulty1–5 of 5
FormatsTrue / false, Short answer, Flashcard, Multiple choice, Find the bug, Design exercise

What you'll review

  1. dead letter queue
  2. message queues

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

True or false: In messaging systems, a dead-letter queue is a queue to which messages that exceed the configured maximum number of processing retry attempts are automatically routed for later inspection or manual re-processing.#

Options

Show answer

True. A dead-letter queue (DLQ) is a secondary queue that receives messages once they exceed the configured maximum number of processing retries. This keeps poison messages out of the main queue so they can be inspected or reprocessed manually.

Why:

A dead-letter queue is defined by its routing behavior: when a consumer fails to process a message within the allowed retry count, the broker or consumer framework moves that message out of the main queue into the DLQ. There it is kept for later analysis, debugging, or manual re-processing, so it stops blocking or repeatedly failing the main flow. The statement describes exactly this defining behavior, so it is true.

In a message-based system using a dead-letter queue, what is the primary role of the dead-letter queue?#

Show answer

A dead-letter queue holds messages that failed processing after exhausting the configured retry attempts, so they can be inspected and possibly reprocessed without blocking the main queue.

Why:

A dead-letter queue is a dedicated queue that receives messages that failed processing after the system's configured retry attempts are exhausted. It keeps these problematic messages out of the main pipeline so they can be inspected, debugged, and optionally reprocessed, rather than repeatedly blocking or poisoning the active queue.

What is a dead-letter queue (DLQ)?#

Show answer

A dead-letter queue is a dedicated queue that receives messages which could not be successfully processed after a configured number of retry attempts. It lets operators inspect, debug, and reprocess those failed messages without blocking the main processing pipeline.

Why:

A dead-letter queue (DLQ) is a specialized queue that captures messages which failed processing after exhausting configured retries. It separates unprocessable messages from the main queue, which enables debugging and reprocessing without blocking normal message flow. The question asks for a definition in the reader's own words, so it is an open answer graded by keywords rather than a choice or blank.

What is a dead-letter queue (DLQ) and what problem does it solve in a message-based system?#

Show answer

A dead-letter queue is a secondary queue where messages that cannot be processed successfully — typically after exceeding a configured retry or receive-count limit — are automatically routed so they can be inspected, debugged, and optionally replayed later, instead of being retried indefinitely or dropped silently.

Why:

A DLQ isolates problematic messages so they do not block the main queue or cause infinite retry loops. It gives operators a safe place to inspect failures (poison-pill messages, bad payloads, downstream outages) and replay them once the root cause is fixed, while normal traffic continues flowing through the primary queue.

In a typical message-queue system (e.g., AWS SQS with a redrive policy), which scenario causes a message to be moved to a dead-letter queue?#

Options

Show answer

A message is moved to a dead-letter queue when it exceeds the configured maximum receive count or retry limit without being successfully acknowledged by a consumer. Successful processing, new subscriber connections, and initial queue creation never trigger dead-letter routing.

Why:

A dead-letter queue receives messages that have failed processing repeatedly. When a message's receive count exceeds the configured maximum (e.g., SQS maxReceiveCount) without a successful ack/Delete, the broker routes it to the DLQ. Successful acknowledgements remove the message from the main queue entirely; new consumer subscriptions and initial queue creation are unrelated lifecycle events that never trigger DLQ routing.

Which statement correctly describes the role of a Dead Letter Queue (DLQ) in a message-oriented architecture?#

Options

Show answer

A Dead Letter Queue is a secondary queue that receives messages after they exhaust their configured retry attempts on the main queue. It isolates poison-pill messages so they can be inspected or reprocessed without blocking healthy traffic on the main queue.

Why:

A Dead Letter Queue isolates messages that fail processing after exhausting configured retries, so they can be inspected and reprocessed later without stalling the main queue. Holding messages for inactive subscribers, replicating the queue for disaster recovery, and restoring FIFO order are separate concerns handled by different mechanisms, so the option describing a secondary queue for retry-exhausted messages is the only correct one.

An order-processing service consumes messages from a queue. Occasionally a message contains malformed JSON that causes the consumer to throw an exception every time it attempts to process it. Because the queue's redelivery logic keeps re-delivering the same message, subsequent healthy messages are starved and throughput drops to near zero.<br><br>Which pattern most directly prevents a single unprocessable message from blocking the queue?#

Options

Show answer

Move messages that exceed a maximum retry count to a dead-letter queue (DLQ) so they no longer block the main queue. A 'poison pill' message — one that always fails, such as malformed JSON — would otherwise be redelivered indefinitely and stall processing. The DLQ isolates such messages for later inspection or manual reprocessing, while healthy messages continue flowing through the main queue.

Why:

A dead-letter queue (DLQ) is a secondary queue that receives messages the consumer failed to process after a configured retry limit. When a 'poison pill' message — one that always fails, such as malformed JSON — keeps being redelivered, the DLQ pattern diverts it out of the main queue so it no longer blocks healthy messages. The failed message is preserved for inspection, debugging, or manual reprocessing once the root cause is fixed. Increasing concurrency does not solve the problem because the bad message will still be redelivered and fail repeatedly; it merely delays starvation. Shortening retention silently discards data without giving operators a chance to diagnose the failure. Changing the delivery model (pull vs. push) is orthogonal — a push-based consumer still receives the same poison-pill message and will still fail on it.

A message consumer crashes with a deserialization error every time it processes a particular message, causing the broker to keep redelivering it — consuming CPU indefinitely. Which mechanism is specifically designed to break this loop?#

Options

Show answer

A dead-letter queue (DLQ) breaks the loop: after a configured number of delivery attempts the broker routes the failing message to the DLQ for inspection, freeing the main queue to keep processing healthy messages. Engineers can then diagnose the bad payload at their own pace. Switching to at-most-once or a short TTL silently drops the message, and adding consumers just spreads the same deserialization crash to more nodes.

Why:

A dead-letter queue is the correct tool: after a configurable retry ceiling (e.g. 5 delivery attempts) the broker automatically moves the problematic message to a separate DLQ so it can be inspected, replayed, or discarded without blocking the main queue. The consumer keeps processing the rest of the stream while engineers diagnose the bad payload at their own pace. Switching to at-most-once silently drops messages on failure — you lose the event permanently without knowing why it failed. A short TTL is a blunt forced expiry that also loses the message with no diagnostic value. More consumers just propagate the crash to more instances — every consumer hits the same deserialization error on the same payload, amplifying the problem rather than containing it.

In a dead-letter queue (DLQ) pattern for an at-least-once delivery system, a consumer reads messages from a Kafka topic. The system applies retry-with-exponential-backoff before moving a message to the DLQ. Which scenario should route a message to the DLQ immediately, with zero retries?#

Options

Show answer

A message whose payload fails JSON schema validation during deserialization should go straight to the dead-letter queue with zero retries. The defect is in the message content, so retrying the same payload can never succeed. Timeouts, broker disconnects, and temporary database outages are transient and should be retried with backoff first.

Why:

A payload that fails JSON schema validation has a permanent, content-level defect: the message itself is structurally invalid, so retrying the same bytes will fail every time. Routing it straight to the DLQ avoids wasting retry budget and downstream capacity. The other three scenarios are transient infrastructure failures: a downstream timeout, a dropped broker connection, and a temporarily unavailable database may all succeed on a later attempt, so they should be retried with exponential backoff before any DLQ routing is considered.

Design a dead-letter queue (DLQ) subsystem for an order-processing microservice architecture. The main pipeline consumes events from a Kafka topic, processes payments, updates inventory, and sends notifications. Messages can fail due to transient issues (downstream timeouts, rate limits, brief database unavailability) or permanent issues (schema violations, invalid references, poison-pill payloads that crash the consumer). Your design must address: (1) how failures are classified and routed, (2) the retry policy including backoff and the threshold for DLQ placement, (3) how DLQ messages are inspected and re-injected into the pipeline, and (4) how the system prevents unbounded reprocessing loops. Provide your architecture, key components, and any trade-offs.#

Show answer

Classification: the consumer maps each exception to a category. Transient errors (timeouts, rate limits, connection drops) are retried; permanent errors (schema violations, unknown entity references, unparseable or poison-pill payloads) skip retries and go straight to the DLQ topic. Retry policy: transient failures use exponential backoff with jitter (for example base 100ms doubled per attempt, capped at 60s) for a bounded number of attempts, such as 5; when the budget is exhausted the message is moved to the DLQ, a separate Kafka topic with longer retention. Each DLQ record keeps the original payload plus metadata: failure class, error message, stack trace, retry history, source topic, and original offset. Inspection and re-injection: a DLQ dashboard shows depth, message age, and failure-type breakdown with alerts on thresholds; an ops tool displays payload and metadata, and after the root cause is fixed a replay endpoint re-publishes the message to the main topic with its retry count reset. Loop prevention: each message carries a requeue count incremented on every re-injection; past a threshold (for example 3) it is parked in a manual-review queue that needs human approval before another retry. Trade-offs: backoff adds latency for messages that eventually succeed but protects downstream services from retry storms; the requeue cap stops automation from masking persistent bugs but can delay fixable messages until a human reviews them.

Why:

A robust DLQ design separates transient from permanent failures so that retriable errors get bounded exponential backoff with jitter while permanent errors go straight to a dead-letter store. Messages that exhaust the retry budget land in a separate topic with enriched metadata, and tooling lets operators inspect and replay them after the root cause is fixed. Loops are prevented by tracking a requeue count per message and gating further retries behind a cap or a manual-review step, which bounds reprocessing while accepting some latency and human effort as the trade-off.

In a message-processing system that uses a dead-letter queue, which failure category should be retried with exponential backoff before the message is sent to the DLQ, rather than being routed to the DLQ on the first failure?#

Options

Show answer

Transient failures should be retried with exponential backoff before a message goes to the dead-letter queue. Timeouts, brief database outages, and rate-limit responses often succeed on a later attempt. Schema errors, poison pills, and oversized messages fail identically on every retry, so they belong in the DLQ right away.

Why:

A DLQ routing decision depends on whether a failure is transient or permanent. Transient failures, such as a downstream timeout, a brief database outage, or a rate-limit response, can succeed on a later attempt, so retrying with exponential backoff before DLQ placement is worthwhile. The other choices are permanent for the same message: a schema-validation failure from a malformed payload, a poison-pill message that deterministically crashes the consumer, and a message exceeding the broker's maximum size are rejected identically on every delivery, so retries only waste capacity and the message should be routed to the DLQ immediately.

In an asynchronous message-processing system that uses a dead-letter queue (DLQ), the consumer reads messages from the primary queue and attempts to process each one. Under which condition should the message be routed to the DLQ rather than retried on the primary queue?#

Show answer

A message should be routed to the DLQ when it has exhausted all configured retries, meaning transient failures keep recurring past the retry limit, or when the failure is non-transient, such as a malformed payload or schema violation that no retry could fix. A transient failure with retries remaining, like an HTTP 503 or 429, should be retried with backoff on the primary queue instead.

Why:

A dead-letter queue holds messages that cannot be processed successfully, either because all configured retries have been used up on failures that kept recurring, or because the failure is non-transient (for example a malformed payload or schema violation) so retrying would never help. A transient failure with retries remaining, such as an HTTP 503 or a 429 Too Many Requests, should be retried with exponential backoff rather than dead-lettered. Consumer overload is a load-shedding concern handled by backpressure or rate limiting, not by moving individual messages to the DLQ.

You are designing the failure handling for an order-processing pipeline on AWS SQS (standard queues only). Orders sit on a queue named orders.processing and are consumed by workers that call payment, inventory and shipping APIs. Some messages fail because a downstream service is briefly unavailable (transient), and others fail because the message itself is malformed (permanent poison pill). Describe your design and cover: (1) the SQS redrive configuration that moves repeatedly failing messages to a dead-letter queue, and how a worker sends a permanent poison pill to that DLQ immediately instead of waiting for the receive count to reach its limit; (2) how exponential backoff of roughly 1s, 2s, 4s, 8s, 16s is implemented, given that SQS has no native backoff setting; (3) how the DLQ is monitored and how its messages are replayed after the root cause is fixed; (4) how the worker distinguishes transient errors from permanent ones.#

Show answer

(1) Create a orders.dlq queue and attach a redrive policy to orders.processing that sets deadLetterTargetArn to the DLQ ARN and maxReceiveCount to 5. SQS moves a message to the DLQ on its own once a receive would push the message's ReceiveCount past that limit without the message being deleted. Redrive counts only receives, so a worker that identifies a poison pill does not wait for it: it calls SendMessage to orders.dlq with the failure reason as a message attribute, then calls DeleteMessage on the source queue. (2) SQS has no native backoff, so the worker implements it with visibility timeouts. On a transient failure it calls ChangeMessageVisibility on the received message, setting the timeout to min(2^(ReceiveCount-1), 16) seconds plus a random jitter of up to one second, where ReceiveCount comes from the ApproximateReceiveCount attribute. The message is hidden for that interval and then becomes visible again. (3) A CloudWatch alarm on the ApproximateNumberOfMessagesVisible metric of orders.dlq pages the on-call engineer whenever the DLQ holds any messages. After the root cause is fixed, the messages are replayed with SQS's StartMessageMoveTask API, which moves them from the DLQ back to orders.processing, or with a small consumer that receives from the DLQ, resends each message to the source queue and deletes it from the DLQ. (4) The worker classifies errors. Timeouts, HTTP 5xx and HTTP 429 are transient: the worker leaves the message un-deleted and applies the visibility backoff. Schema validation failures, missing required fields and other HTTP 4xx responses are permanent: the worker dead-letters the message immediately as described in part (1). A validation step before processing rejects structurally invalid payloads before any retry is attempted.

Why:

A strong answer stays on one broker, AWS SQS, so every mechanism is concrete. The redrive policy with maxReceiveCount is the only automatic route to the DLQ, and it counts receives, so a poison pill needs an explicit SendMessage to the DLQ followed by DeleteMessage on the source queue to be dead-lettered immediately. SQS has no backoff setting, so exponential backoff is implemented by setting a per-message visibility timeout with ChangeMessageVisibility from the receive count, plus jitter. Monitoring uses a depth alarm on the DLQ, and replay uses StartMessageMoveTask or a resend consumer once the cause is fixed. Errors are split into transient (timeouts, 5xx, 429), which retry with backoff, and permanent (schema or 4xx bad-message failures), which are dead-lettered immediately, with pre-validation as a first gate. The keywords check is only a rough guide; a grader should judge whether each of the four parts is addressed with a correct mechanism.

What is a dead-letter queue (DLQ) and when does a message end up there?#

Show answer

A DLQ is a side queue where a message broker parks messages that cannot be successfully processed after exhausting retries. A message lands in the DLQ when: it has been delivered and negatively acknowledged (nack) more times than the configured maxReceiveCount, its TTL expires before a consumer picks it up, or the message is malformed and rejected by consumer validation. DLQs prevent poison messages from blocking the main queue indefinitely, allow operators to inspect failures without data loss, and enable replaying fixed messages back to the main queue after the root cause is resolved.

Why:

Without a DLQ, a single unprocessable 'poison' message cycles forever, blocking queue progress or consuming retries that could serve real work. DLQs make failure observable and recoverable. The companion alarm pattern is to alert when DLQ depth rises above zero, treating any DLQ message as a bug requiring investigation.

This worker pulls messages off a queue and processes them. A single malformed message has brought the whole consumer to a halt — no other message gets processed. What is the bug?#

// queue.receive() blocks until a message is available
while (true) {
  const msg = queue.receive();
  try {
    process(msg);          // throws on a malformed message
    queue.ack(msg);
  } catch (err) {
    queue.requeue(msg);    // put it back so we don't lose it
  }
}

Options

Show answer

A message that always throws (a 'poison pill') is requeued endlessly with no attempt limit, so it loops forever at the head of the queue and starves every other message; it needs a redelivery counter that routes to a dead-letter queue after N attempts

Why:

The message is a poison pill: it deterministically throws, the catch block requeues it with no attempt limit, and (in a FIFO queue) it returns to the head and is retried forever — blocking every message behind it. The fix is to bound redeliveries (track an attempt count or use the broker's max-receive setting) and route the message to a dead-letter queue after the threshold, so the poison message is quarantined for inspection while the rest of the stream flows. The distractors are wrong: ack-after-process is the correct at-least-once ordering, not the bug — acking first would silently lose messages on a crash; the infinite while loop is the intended consume loop, not a memory leak; and changing requeue to ack on failure would discard every failed message, replacing a stall with silent data loss.

Design a multi-channel notification system: a platform service that other services call to send notifications to users over push, email, SMS, and in-app.#

Show answer

Requirements. A single send API fans to four channels, each fronted by a third-party provider with its own rate limit and failure profile. Two priority tiers: transactional (OTP, < 5 s) and marketing (batchable). First-class requirements beyond delivery: idempotency (never double-send), preferences/opt-out, retry, and an audit trail.

Pipeline. The send API does almost nothing synchronously — it validates and enqueues the event onto a message queue, then returns. Per-channel workers consume from their queue and call the provider. This decoupling is the backbone: it absorbs the 30K/sec peaks, and a slow provider only backs up its queue, not the others. Templating (render the message body from a template + data) happens in the worker just before send.

Dedup & idempotency. Each event carries an idempotency key (event_id:user_id:channel). Before sending, the worker does an atomic check-and-set against an idempotency store; if the key already exists, it's a duplicate and is dropped. This turns the queue's at-least-once delivery into at-most-once per recipient per channel, so an upstream retry can't double-send.

Reliability. Transient provider errors are retried with exponential backoff + jitter. A message that exhausts its retries (or is malformed/poison) goes to a dead-letter queue for inspection rather than blocking the worker. Because each channel has its own queue and worker pool, a failing SMS provider can't stall push or email.

Preferences. Before dispatch, the worker checks the user's preferences/opt-out for that channel and any per-user frequency cap (so we don't spam someone with ten pushes in a minute), plus compliance rules (quiet hours, unsubscribe for email). A suppressed notification is recorded as suppressed in the audit, not sent.

Scaling & provider limits. Each channel scales its worker pool independently. Workers pace themselves with a token bucket matched to the provider's rate limit, applying backpressure to the queue rather than overrunning the provider. Priority queues (a separate high-priority lane per channel) let an OTP jump ahead of a 50M-message marketing backlog so it still meets its < 5 s budget.

Why:

A notification system is fundamentally an asynchronous, queue-backed pipeline problem. The defining move is decoupling ingestion from delivery: the send API just enqueues, and per-channel workers deliver — which is what absorbs traffic spikes and stops one slow third-party provider from stalling the others. The two correctness pillars are idempotency (an idempotency key like event:user:channel checked before send turns the queue's at-least-once delivery into at-most-once per recipient, so upstream retries never double-send) and reliability (backoff retries plus a dead-letter queue for poison messages). Preferences/opt-out and per-user frequency caps must be enforced before dispatch, and priority queues are what let a latency-critical OTP overtake a bulk marketing backlog.

Design a distributed task / job queue (think Celery / Sidekiq / SQS-backed workers): producers submit background jobs, a fleet of workers executes them, and the system must not lose work or run a job twice in a way that corrupts state.#

Show answer

Requirements. The system has two halves: submit (cheap, synchronous — durably record the job and return) and execute (asynchronous, on a worker). Jobs vary wildly in duration (10 ms to minutes) and need scheduling and priority. The crucial semantic is delivery: I'll deliver at-least-once and make handlers idempotent, which gives exactly-once effect even for charge-card — true exactly-once delivery across a crash boundary is not achievable, so I don't promise it.

Queue & leasing. Jobs go into a durable, replicated broker (Kafka, SQS, or a Redis stream). A worker doesn't delete on dequeue — it leases the job with a visibility timeout (or in-flight/ack semantics): the job is hidden from other workers while being processed and is only acked (removed) on success. If the worker crashes, the lease expires, the job reappears, and another worker runs it. This is what guarantees no lost jobs on crash, at the cost of possible re-delivery.

Delivery semantics & idempotency. Because re-delivery is possible, every side-effecting handler is idempotent, keyed by a job/idempotency id. For charge-card: before charging, the worker does an atomic check-and-set on idempotency_key in a store; if it's already marked done, it skips the charge and just re-acks. So the second worker that picks up the re-delivered job sees the key, does nothing, and acks — the card is charged exactly once even though the job was delivered twice.

Retry, DLQ, scheduling, priority. Transient failures retry with exponential backoff + jitter (bounded attempts). A job that exhausts retries — or is malformed/poison — is moved to a dead-letter queue for inspection rather than looping forever. Scheduled jobs go to a delay queue or a timestamp-indexed store that a promoter moves into the ready queue when due. Priority is separate lanes (high/default/low) or a priority field, so urgent jobs jump ahead.

Scaling the queue & fleet. The broker is partitioned (by job type or key hash); throughput scales with partition count and worker count. The fleet autoscales on queue depth / consumer lag. Critically, long-running jobs get their own queues and worker pools, isolated from latency-sensitive ones — so a flood of 5-minute transcodes drains its own pool and never sits in front of send-email.

Failure modes. Broker down: it's a replicated durable log, so it tolerates node loss; producers buffer briefly. Worker crash mid-job: lease expiry → redelivery (idempotency makes that safe). Poison job: capped at N attempts then DLQ, so it can't crash workers forever. Head-of-line blocking: per-type queues plus priority lanes keep one backlog from starving the rest.

Why:

A distributed job queue is the canonical at-least-once + idempotency system. The defining move is leasing instead of delete-on-dequeue: a worker hides a job with a visibility timeout and only acks on success, so a crash mid-job makes the job reappear and re-run rather than vanish — which is exactly why no work is lost. The price of that guarantee is possible re-delivery, so every side-effecting handler must be idempotent (an idempotency key checked before the side effect), which is what turns at-least-once delivery into exactly-once effect even for a charge-card. The supporting machinery is backoff retries with a dead-letter queue for poison jobs (so one malformed job can't loop forever), scheduled/priority lanes, and — the most-missed point — isolating long-running jobs in their own pools so a transcode backlog never blocks fast jobs (head-of-line blocking).

A high-throughput e-commerce platform processes ~50,000 order events per second from a Kafka topic orders, consumed in a consumer group by a microservice that persists orders to a database and triggers downstream fulfillment. Some messages cannot be processed because of schema incompatibility, invalid payload data, or a downstream dependency outage that causes timeouts. Design a dead-letter queue (DLQ) strategy so unprocessable messages are quarantined, inspected, and replayed without losing orders and without blocking the main pipeline.#

Show answer

Routing: Classify each failure at the consumer. Non-retryable failures (deserialization error, schema mismatch, validation failure) go straight to the DLQ topic orders.dlq. Transient failures (timeouts, downstream 5xx) are not retried in-line, because a blocking backoff of seconds would stall the partition at 50K msgs/sec. Instead they are republished to tiered retry topics (for example orders.retry.1 with a 1-minute delay and orders.retry.2 with a 10-minute delay). The attempt count travels in a Kafka record header (x-attempt) and is incremented on each republish, so no external state store is needed. After the final tier fails, the message goes to orders.dlq. The consumer commits the source offset only after the republish to the next tier or to the DLQ is acknowledged by the broker, which preserves at-least-once delivery. A delay on a retry tier is enforced by a consumer on that tier that holds only its own partition until the record's due time, so the main topic is never blocked.

DLQ record: The original payload is wrapped in an envelope with originalTopic, originalPartition, originalOffset, originalTimestamp, messageId / correlationId, attemptCount, firstFailureTimestamp, lastFailureTimestamp, failureType (transient or non-retryable), errorCode, a truncated errorMessage and stack trace, consumerVersion, and the source headers. The original message key is also kept so replay can route by key. These fields support triage, filtering by error type, and tracing back to the source record.

Replay: An operator-triggered replay job reads a selected DLQ range, filters by error code and failure type, and republishes each payload to orders using the original message key. Under the default partitioner the key determines the partition as long as the partition count is unchanged, so per-key placement is preserved, but the original partition number is not guaranteed to be restored. Replay cannot guarantee ordering against messages that were processed normally after the failure, so ordering must be handled by the consumer. Replayed messages must be applied idempotently: database writes use upsert on the order key (INSERT ... ON CONFLICT (order_id) DO UPDATE), with version or timestamp comparison so an older event never overwrites a newer state. External calls carry an idempotency key derived from messageId, and the fulfillment service deduplicates on messageId within a bounded window.

Observability: Export DLQ depth, oldest-message age, ingress rate, and counts by failureType and errorCode. Alert on depth above an assumed threshold (for example 1,000 messages), on oldest-message age above an assumed threshold (for example 1 hour, meaning triage is falling behind), and on ingress rate sustained above a multiple of the trailing 7-day baseline, such as 3x for 5 minutes, which signals a systemic cause rather than isolated poison messages. At a 0.01% poison rate the baseline is about 5 msgs/sec (~432K/day). A dependency outage is handled by a circuit breaker that pauses consumption and holds the partition, rather than pushing all 50K msgs/sec through retries into the DLQ, so DLQ ingress during an outage is bounded by what exhausts the retry tiers. The dashboard plots DLQ ingress against upstream per-error-code failure rates to identify the change that caused a spike.

Retention: Set retention.ms to an assumed 7 days, with a size cap sized from measured ingress plus margin, and archive records to cold storage (for example an S3 sink with lifecycle rules) before expiry for compliance and post-mortems. Alerts fire before the cap is reached so messages are not silently dropped.

Why:

The corrected answer is a design rather than a single exact policy, so it is graded on whether the reasoning is internally consistent. Transient failures use tiered retry topics instead of blocking in-consumer backoff, which keeps the 50K msgs/sec partition moving, and the attempt count lives in a header carried with the record so no external store is needed. Offsets are committed only after the next-tier or DLQ publish is acknowledged, preserving at-least-once delivery. Replay reuses the original message key, which keeps per-key placement under an unchanged partition count, while stating that the original partition number is not restored and that ordering relative to later messages is not guaranteed; that is why consumers must be idempotent and version-aware. The capacity math is stated with its assumptions: the 5 msgs/sec baseline follows from 0.01% of 50K, and a dependency outage is handled by a circuit breaker so the DLQ does not receive the full stream. Thresholds and retention are labelled as assumed choices, not universal standards.

A microservice consumes messages from an Amazon SQS standard queue. The queue has a redrive policy that moves messages to a dead-letter queue (DLQ) after 5 receive attempts. The service uses at-least-once processing and occasionally crashes after completing its business logic but before deleting the message from SQS. After a production bug is fixed, you plan to replay all messages from the DLQ back through the original queue. Which statement is correct?#

Options

Show answer

Replaying an SQS dead-letter queue requires an idempotent consumer. SQS dead-letters messages based on receive count, not on whether processing succeeded, so a message whose work finished before a crash can end up in the DLQ. Replaying it without idempotency would repeat side effects such as duplicate charges or records.

Why:

SQS moves a message to the DLQ based only on how many times it has been received (ReceiveCount) reaching the redrive threshold, not on whether processing succeeded. A consumer can complete the business logic and then crash before deleting the message, so the message returns to the queue, gets received again, and is eventually dead-lettered even though its work was already done. Replaying such messages through a non-idempotent consumer would repeat those side effects, so the operation must be idempotent. A longer visibility timeout does not remove the crash-after-processing case, and DLQ messages are ones that were received multiple times, so they are not unprocessed.

Design a dead-letter queue (DLQ) strategy for an event-driven payment processing system. Payment events arrive on a Kafka topic and flow through a chain of microservices (fraud check, ledger entry, notification), each consuming from its own topic and publishing to the next stage's topic. The system must handle poison-pill messages (messages that will always fail, such as unparseable payloads or unsupported currencies) without blocking the pipeline or losing data. Your design should cover: (1) the routing criteria that decide when a message lands in the DLQ, (2) the retry strategy preceding DLQ routing, (3) the DLQ message schema and metadata, (4) alerting and observability for DLQ health, and (5) the replay and recovery procedure for dead-lettered messages.#

Show answer

Each stage consumes from its input Kafka topic, processes the event, and publishes to the next stage's topic. Each consumer has a per-stage dead-letter topic. Routing criteria: a message goes to the DLQ either after exhausting a bounded retry budget (default 5 retries) or immediately on a terminal, non-retryable error such as schema validation failure, unparseable payload, or a business-rule rejection like an unsupported currency. Transient errors (downstream timeouts, rate-limit responses) are retried, so poison pills never occupy consumer capacity indefinitely. Retry: retryable failures use exponential backoff with jitter (up to about 20%) to avoid thundering-herd effects, bounded by a maximum retry count and a maximum total time window. In Kafka this is implemented with a retry-topic pattern using per-attempt delay topics or a delay-aware scheduler. Unbounded retries would let one poison pill block a consumer or fill the retry topic, creating back-pressure across the pipeline. DLQ schema: each DLQ record wraps the original payload in an envelope with original topic, partition, offset, the failing stage, exception type and message, truncated stack trace, first-failure and last-attempt timestamps, retry count, a schema version, and a correlation ID equal to the original payment event ID. This supports both automated replay and human forensics. Alerting and observability: emit metrics for DLQ depth, DLQ write rate, error-type histograms by exception and failure reason, and age of the oldest DLQ message. Alert when depth crosses a threshold (for example more than 100 messages in 5 minutes) or when the write rate jumps above baseline, which often signals a deployment regression. Grouping by error type distinguishes one poison pill (one message, one reason) from a systemic bug (many messages, same reason), and dashboards overlay deployment markers. Replay and recovery: a dedicated replay service re-injects messages into the pipeline entry point or the failed stage, keyed by correlation ID, after an operator or automated policy approves. Every stage is idempotent, using keys such as payment ID plus stage name, so a partially completed message does not double-write ledger entries or send duplicate notifications. Messages that keep failing after N replay attempts move to a quarantine state for manual review. Schema evolution is handled by versioned envelopes: the replay service applies migration shims to upgrade old payloads to the current contract, or flags messages whose version cannot be migrated for manual triage.

Why:

This is an open design question that asks the candidate to construct a complete DLQ strategy, so it is correctly a SHORT_ANSWER graded against the sample answer and keywords rather than a closed-choice format. It tests whether the candidate can separate transient from terminal errors, bound retries with backoff and jitter, design a metadata-rich DLQ envelope, instrument DLQ health, and perform idempotent replay with schema migration. These are senior-level concerns, which matches difficulty 4.

In a Kafka-based event processing system, a consumer reads from a main topic with at-least-once delivery semantics. On processing failure, the consumer publishes the failed message to a dead-letter topic and then commits its consumer offset. Assume no transactions or exactly-once semantics are configured, so the DLQ publish and the offset commit are independent operations, and the DLQ topic uses a different key space from the main topic with no cross-topic deduplication.#

Show answer

The message appears twice in the dead-letter topic. The first DLQ publish succeeded before the crash and was not rolled back, because the DLQ write and the offset commit are independent operations with no transaction spanning both. Since the offset was never committed, the consumer re-reads the same message after restart, fails it again, and publishes a second, independent DLQ record. Under at-least-once delivery, the DLQ topic therefore receives a duplicate that consumers of the DLQ must handle, for example by deduplicating on a message identifier.

Why:

Under at-least-once delivery, the DLQ publish is a separate producer write to a different topic and is not coupled to the consumer offset commit. The crash after the DLQ write but before the offset commit leaves the DLQ record in place, since no transaction spans the two topics. On restart the uncommitted offset causes the same message to be re-consumed, processing fails again, and a second DLQ record is written. The answer is therefore two independent records for the same message, which is the duplication that at-least-once semantics permit at the DLQ boundary.

Design a dead-letter queue (DLQ) subsystem for a large-scale event-driven microservices platform processing 500K events/second across 200+ microservices. Each microservice consumes from Kafka topics and may fail to process events due to downstream API timeouts, schema incompatibilities, transient infrastructure issues, or business-rule violations. The platform requires: (1) failed events retried with exponential backoff and jitter, (2) a maximum retry limit before events are moved to a terminal dead-letter store, (3) an operational dashboard for on-call engineers to inspect, reprocess, or discard dead-lettered events, (4) a 30-day maximum data retention requirement, and (5) idempotent reprocessing to prevent duplicate side effects. Design the DLQ architecture including topic structure, retry mechanics, metadata tracking, replay/reprocessing strategy, observability, and how you handle the dead-letter-of-the-dead-letter recursion problem.#

Show answer

Topic structure: For each service's main topic events.{service}, use tiered retry topics with increasing delays (for example events.{service}.retry.0 through events.{service}.retry.3, roughly 2s, 10s, 60s, 10min) and a terminal events.{service}.dlq topic. Delays are enforced by a retry-scheduler service that holds messages and republishes them to the source topic when the backoff window elapses, because Kafka has no native per-message delay. The DLQ topic is drained into a durable terminal store (DynamoDB or a database table) for inspection.

Retry mechanics: On failure the consumer computes delay = min(cap, base * 2^attempt) and adds random jitter (for example full jitter in [0, delay]) so that messages failing during a downstream outage do not all retry at the same instant and cause a thundering herd when the dependency recovers. After a maximum retry count (for example 5) the event is published to the DLQ. Errors are classified (timeout, schema_violation, business_rule, infrastructure) so that non-transient failures such as schema or business-rule violations go straight to the DLQ instead of consuming retry budget.

Metadata envelope: Each dead-lettered record wraps the original payload with original_topic, original_partition, original_offset, first_failure_timestamp, last_failure_timestamp, retry_count, error_type, error_message, stack_trace, trace_id/correlation_id, source_service, and consumer_group. This supports filtering by error type, time range, or correlation ID and traceability back to the source record.

Idempotent replay: Every event carries a producer-assigned event_id (UUID) preserved through retries and replay. Consumers record processed event_ids in an idempotency store (a DB table with a unique constraint, or Redis with TTL at least as long as the replay window) and skip side effects for already-processed events. This makes replay safe even if a replay worker crashes mid-batch and re-sends events. Replay is driven from the dashboard by event or offset range: a replay worker reads the DLQ record, unwraps the original payload, and republishes it to the original main topic with its event_id intact, throttled to protect downstream systems.

Dead-letter-of-the-dead-letter recursion: The replay path is itself a consumer and can fail, so it gets a bounded retry budget (for example 3 attempts with backoff). Events that exhaust it move to a terminal store with no consumer and no automatic retry, which is a dead end requiring manual action and structurally prevents infinite loops. Writing to the terminal store raises a high-severity alert. A circuit breaker on the DLQ/replay consumer's failure rate (for example over 10% in 5 minutes) halts replay to avoid cascading failure and pages on-call.

Retention and observability: The DLQ topic and terminal store use time-based retention capped at 30 days (Kafka retention.ms or DynamoDB TTL), with per-topic configuration allowed below that cap. The dashboard offers a filterable paginated list, a detail view with the full envelope and payload, single and batch replay, and discard for unrecoverable events. Metrics include DLQ depth, inflow and outflow rates, age of the oldest message, failure rate by error type, and terminal-store depth, with alerts on depth thresholds, any terminal-store write, and circuit-breaker trips.

Why:

This is an open architecture question with no single correct answer, so it stays a SHORT_ANSWER graded by keyword coverage and a reference answer. A strong answer must cover the full DLQ lifecycle: tiered retries with exponential backoff and jitter to avoid thundering herds, a bounded retry limit that routes events to a terminal store, a metadata envelope that preserves traceability to the source record, idempotent replay keyed by a preserved event identifier so repeated replays cause no duplicate side effects, a recursion break for the replay path (bounded retries, a terminal store with no automatic consumer, alerting and a circuit breaker), and retention capped at 30 days with dashboard and metrics support. The reference answer notes that Kafka lacks native per-message delay, so delays need a scheduler service, which avoids an incorrect claim about built-in delayed delivery.

Related interview questions

Job market

See system-design salaries and hiring demand from live job postings.

Practise these until they stick

That's every question we hold on this topic, and the page marks what you pick. What it can't do is remember. A free account keeps every answer, and what you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 answers per 30 days, each marked with written feedback

Interview booked? Practise the job ad instead

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.