SimuVedaSystem Design Lab Open in the lab

Data platform / Intermediate / 5 min / Updated

Exactly-once processing: at-most, at-least and idempotent

A worker charges cards from a queue and crashes. Commit first and orders are lost, charge first and some are billed twice, idempotency keys fix it.

Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.

In short

What is exactly-once?

Delivery guarantees say how often a message is processed when workers crash: at most once, at least once, or effectively once.

Why does it matter?

Payments, emails and counters must not be lost or doubled when a worker dies mid-message.

What is the trade-off?

At-least-once plus idempotency is the practical path; true transactions only work inside one system like Kafka.

How do you explain it in an interview?

"At-least-once consumers, commit after processing, idempotency key per order stored with a unique constraint."

Check yourself

A worker charges a card, then crashes before committing the offset. What happens with at-least-once delivery?

Answer: The message is read again and the card is charged twice. Delivery is repeated until it is committed; the effect must be made idempotent.

How do real systems get the effect of exactly-once with an outside payment API?

Answer: At-least-once delivery plus an idempotency key, such as the order id, so repeats are skipped. The payment provider or your database rejects a second charge with the same key.

Committing the offset before processing gives which guarantee?

Answer: At most once: a crash loses the message. The queue already thinks the message is done, so it is never delivered again.

See it happen in the simulation →

exactly onceat least onceat most oncekafkaidempotencyoffset commitdelivery guaranteesdata engineering

More in data platform