Delivery guarantees
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Delivery guarantees: at-least-once, exactly-once and DLQs: the 60-second story

    Delivery guarantees

    You pay ₹450 by QR. The screen says “Something went wrong.”

    Walk away, and the shop may never be paid. Pay again, and you may pay ₹900. What got lost was the answer.

    A message crosses three hops. Each picks loss or duplicates.

    End to end, you get the weakest hop. And no broker setting reaches the third: your database write, email or payment call.

    Where does the consumer ack?

    Bad: Ack, then work

    A crash mid-work loses it for good. At-most-once.

    Good: Work, then ack

    A crash means redelivery: at-least-once, the default. Duplicates can be made harmless; losses can’t.

    Can any broker deliver each message exactly once?

    The truth

    Not over a lossy network, because the last ack can always be lost. Build exactly-once effect. Deliver at least once and make repeats change nothing.

    Kafka’s fix for the lost ack: number every batch

    Each producer gets an ID and numbers its batches per partition. A retry with a sequence number the broker already has is acked and dropped.

    Every “exactly-once” feature has a boundary

    1. Idempotent producer: one producer session, one partition
    2. Kafka transactions: Kafka to Kafka, read_committed readers only
    3. SQS FIFO: producer retries within 5 minutes
    4. Pub/Sub: pull subscribers in one region

    One poison message can stall a whole Kafka partition

    It fails every time, so the consumer can’t commit past it. After a few attempts, move it to a dead-letter queue for a human.

    450K

    good messages dead-lettered in a 10-minute outage

    Say 1,000 a second, a 30 s visibility timeout, maxReceiveCount=5. DLQs are for broken messages; for an outage, back off longer or pause.

    Remember

    Exactly-once delivery is impossible. Deliver at least once, make repeats change nothing, and dead-letter what never succeeds.