Try
↑ ↓ move↵ openesc close
In this lesson · topic 3 of 7
  1. 1. The ack point
  2. 2. Three orders, and what exactly-once means
  3. 3. Crash a consumer around the ack
  4. 4. Slow is not dead: duplicates without a crash
  5. 5. Retry limits and the dead-letter queue
  6. 6. Publishing without losing the event
  7. 7. Duplicates, timeouts and exactly once: three checks

Topic 3

Crash a consumer around the ack

7 min read

Compare the three modes

The lab below runs all three modes on the same messages and the same crashes. Each square in a panel is one finished message. A green square was processed once. A crossed red square was lost. An amber square with two bars was processed more than once. Under the squares, the model line says what the crash settings alone predict, so you can compare it with what the run produced.

Predict before you press play

Consumers crash, some of them between the work and the ack. After a while, which mode shows no lost messages and no repeated side effects?

crash per attempt 20%in the ack gap 50%slow per attempt 0%The model line in each panel is worked out from these three numbers alone.

At most once (ack, then work)

Each square is one finished message, oldest first. Filled green: processed once. Crossed red: lost. Amber with two bars: processed more than once.

lost
14
processed twice+
0
extra effects
0
redeliveries
15
crashes
29
dedupe hits
0

lost 12% model 11%extra effects per message 0.000 model 0.000

At least once (work, then ack)

Each square is one finished message, oldest first. Filled green: processed once. Crossed red: lost. Amber with two bars: processed more than once.

lost
0
processed twice+
12
extra effects
14
redeliveries
30
crashes
32
dedupe hits
0

lost 0% model 0%extra effects per message 0.121 model 0.125

At least once + idempotency key

Each square is one finished message, oldest first. Filled green: processed once. Crossed red: lost. Amber with two bars: processed more than once.

lost
0
processed twice+
0
extra effects
0
redeliveries
30
crashes
32
dedupe hits
14

lost 0% model 0%extra effects per message 0.000 model 0.000

Lost messages, running total
Lost messages, running total. Text version available below the chart.05101520tick 10tick 210tick 400ticksmessages
Duplicate side effects, running total
Duplicate side effects, running total. Text version available below the chart.05101520tick 10tick 210tick 400ticksextra effects

Full-page version with guided experiments: Delivery guarantees lab.

Things to try

  1. Set the share of crashes inside the ack gap to 0. Every mode becomes harmless. Crashes before the first step only cause a redelivery.
  2. Set it to 1 and raise the crash chance. Lost messages climb under at most once, and extra effects climb under at least once.
  3. Turn crashes off, then raise the slow-attempt chance. At least once still repeats work.
  4. Choose the idempotent mode and write the key in a separate step. Count the repeats that come back.
  5. Watch the redelivery count in each panel. It is almost the same with and without the key.

The full-page lab has five guided experiments you can apply with one click.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms