The Tale of Exactly-Once Semantics
Explore the concept of exactly-once semantics within distributed systems. Understand challenges like message duplication due to unreliable networks, and learn strategies such as idempotent operations and de-duplication to ensure that messages are processed only once. This lesson clarifies the difference between message delivery and processing and highlights common delivery semantics like at-most-once and at-least-once.
We'll cover the following...
Multiple deliveries of a message
Various nodes of a distributed system communicate with each other through the exchange of messages.
As the network is not reliable, these messages might get lost. Of course, to cope with this, nodes can retry with the hope that the network will recover at some point and deliver the message.
However, this means that the nodes may deliver messages multiple times because the sender can’t know what really happens.
The following illustration shows what happens when a node doesn’t deliver a message at all.
The following illustration shows a message that a node delivers twice.
This duplicate delivery of a message can create disastrous side effects.
Example consequence
Think about what would happen if the message is supposed to signal the transfer of money between two bank accounts as part of a purchase. The bank may charge a customer twice for a product.