Try
↑ ↓ move↵ openesc close

Delivery guarantees lab

Consumers that crash around the acknowledgement. Compare acking before the work, acking after it, and adding an idempotency key, then count lost messages and duplicate side effects.

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

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+
9
extra effects
10
redeliveries
22
crashes
24
dedupe hits
0

lost 0% model 0%extra effects per message 0.086 model 0.088

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

What to try

Each one sets up a starting point. Then make the change it describes.

  1. Acking first loses messages

    Pick At most once and put every crash inside the ack gap.

    Look for. Every crash after the ack throws a message away for good. The lost count climbs, and nothing is ever processed twice.

  2. Acking last duplicates side effects

    Switch to At least once with the same crashes.

    Look for. Nothing is lost. A crash after the work but before the ack makes the broker redeliver, and the side effect happens a second time.

  3. An idempotency key stops the second effect

    Compare all three modes under the same crashes.

    Look for. Redeliveries still happen in the idempotent mode, but the store recognises the message and skips the effect. Lost and duplicate counts both stay at zero.

  4. A slow consumer is enough

    Turn crashes off and make 20 percent of attempts slower than the ack timeout.

    Look for. The broker gives up waiting and redelivers while the first attempt is still working. At least once duplicates without a single crash.

  5. Writing the key in a separate step

    Choose the idempotent mode, write the key in a separate step, and put every crash in the ack gap.

    Look for. A crash between the side effect and the key write leaves no record, so the retry repeats the effect. The key only helps when it commits together with the effect.

New to the idea? Read the lesson first. Every number here comes from a seeded simulator, so the same seed gives the same run.

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