Unit 6 of 15 · about 4 hours · explain, implement

Retries, poison records, dead letters and bounded backlog

At-least-once delivery retries everything, including the record that will never succeed. Without a dead letter and a bounded backlog, one bad record or one slow consumer stops the whole partition.

You'll be able to

  • Explain why a poison record stalls a strictly ordered partition and how bounded retries plus a dead-letter queue restore progress.
  • Explain the log as a bounded buffer with lag monitoring, and derive how long a backlog takes to drain at spare capacity.
  • Implement a retry-with-dead-letter rule and a lag alert against a retention bound.

Covers

Retries, poison records and dead lettersBackpressure and bounded backlog
1

Read

In this order, only the parts listed

0 of 3 done

  1. Redelivery, dead letters and slow consumersDDIA 2e - Chapters 11 to 13 Batch and Stream Processing

    Chapter 12, Acknowledgments and redelivery through dead letter queues (pp. 493 to 495): crash loops under strong ordering, DLQs with operator decision; When consumers cannot keep up with producers (p. 499): bounded buffer, lag monitoring, one slow consumer affects only itself

  2. Drop, buffer or backpressureDDIA 2e - Chapters 11 to 13 Batch and Stream Processing

    Chapter 12, Messaging Systems (p. 489): the three overload choices, with Unix pipes and TCP as backpressure examples

  3. Backlogs, sidelining and upstream backpressureAWS Builders' Library - Avoiding Insurmountable Queue Backlogs

    Backlogs (drain at spare capacity, with the multitenant spike example); Amazon's approach (sidelining excess traffic, constant work, pushing backpressure upstream); Measuring availability and latency (message age)

2

Focus on

  • A poison record under at-least-once redelivery plus strict per-partition order stops the partition. Bound the retries, then move the record to a dead-letter queue, alert, and let an operator decide to drop, fix or replay it.
  • A log is a large bounded buffer, not an infinite one. Monitor consumer lag in records and in time, and fix slow consumers before their offsets age past retention.
  • Under sustained overload, shed or sideline low-priority work and push backpressure upstream. A backlog drains at spare capacity only, so a short spike can take many hours to clear.
  • Alert on arrival and drain rates with queue depth, never on depth alone. Depth without rates cannot say whether the backlog ever drains.
Common mistakes · 3
  • Retrying a poison record forever. Deterministic failures never succeed, and each retry burns the partition's progress.
  • Treating buffering as backpressure. An unbounded queue delays the failure and hides it until the disk fills or retention drops data.
  • Replaying a dead letter without a fix. The same record crashes the same code path again unless the code or the record changed.
3

Try it yourself

Closed-book, before checking anything

Closed-book, write the retry-with-dead-letter decision rule (deliver while failures stay within budget, dead-letter past it) and the lag alert rule (committed offset versus log end offset, checked against retention).
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.A message missing a required JSON key crashes each consumer that reads it. What happens under strong per-partition ordering, and what is the remedy?Answer

    The partition stalls because the record redelivers forever. Move it to a dead-letter queue after the retry budget, alert, and fix the consumer code or the record before replaying it.

  2. 2.Failures are [0, 2, 3, 1, 4] with maxRetries 2. Which messages are delivered and which go to the dead letter?Answer

    Delivered, delivered, dead letter, delivered, dead letter. A message is delivered while its failure count stays within budget.

  3. 3.A consumer lags past the oldest retained segment. What does it miss, and who else is affected?Answer

    It misses the deleted messages and must skip ahead. Only that consumer is affected; other consumers keep their own offsets.

  4. 4.Arrivals run at twice the drain rate for one hour, then spare capacity is 10 percent of drain. How long to clear the backlog?Answer

    About 10 hours. The backlog holds one drain-hour of work, and with arrivals continuing it shrinks only by the spare 10 percent, so hours.

5

Practice

  • AlgoMaster: Classify Retry Outcomes

    classify returns delivered while the failure count stays within budget else dlq, order-preserving, including the zero-budget edge case

    The judge tests the routing rule only. Wire it to a dead-letter topic plus a lag alert against retention in the mini-project.

You're done when

You can state the retry budget, the dead-letter decision and the drain time for a stated arrival and drain rate, and your consumer alerts before retention drops data.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 16 more in the section
  • DDIA 2e - Chapters 11 to 13 Batch and Stream ProcessingMartin Kleppmann and Chris Riccomini · primary

    Read batch processing, stream processing and the streaming-systems philosophy in order. For every guarantee, mark the source position, operator state, output effect and recovery boundary it actually covers.

  • AWS Builders' Library - Avoiding Insurmountable Queue BacklogsAmazon Web Services · support

    Read it for how backlogs grow and why they take long to drain, and for backpressure, prioritization, sidelining and constant work. Compare its recovery strategies with the bounded backlog and lag measurements of your consumer.

Also in this section