Exactly-once semantics
Exactly-once semantics is a guarantee that each message changes the final result once, even if failures cause it to be sent or read more than once. Networks can always lose an acknowledgement, so systems do not deliver each message once. They deliver at least once and then remove the effect of duplicates, through deduplication, idempotency or transactions.
How it works
In Apache Kafka, an idempotent producer (enable.idempotence=true) tags writes with a producer ID and sequence number, so the broker drops duplicate retries. Transactions then commit output records and consumer offsets together, and readers with isolation.level=read_committed see only committed data. Without this, a consumer that auto-commits offsets every 5 seconds at 2,000 messages per second can reprocess up to 10,000 messages after a crash.
Why it matters in production
Duplicates turn into double counts in metrics, double charges and repeated emails. Kafka transactions only cover reads and writes inside Kafka. Any external side effect, such as a database write or a payment call, still needs an idempotent write keyed on a unique event ID.
See also
On the One2N blog
Disaster recovery for SREs: the practical playbook for RTO, RPO, and cutover
How temporal versioning prevents configuration drift in stream processing
Further reading
