Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

at-most-once and exactly-once

I am studying Distributed Systems and when it comes to the RPC part, I have heard about these two semantics (at-most-once and exactly-once). I understand that the at-most-once is used on databases for instances, when we don't want duplicate execution.

First question:

How is this achieved? How does the server know that it shouldnt execute the request again? It might be a duplicate but it might be a legitimate request as well.

The second question is:

What is the difference between the two semantics in the title? I can read :). I know that at-most-once might not be executed at all but, what does exactly-once do that guarantees the execution?

like image 528
BrunoMCBraga Avatar asked Nov 26 '12 14:11

BrunoMCBraga


People also ask

What is the difference between at most once Vs at least once vs exactly once?

At-most-once is ideal for applications that need high throughput and low latency due to the fire-and-forget nature. It is the default producer and consumer delivery semantic. At-least-once and exactly-once delivery will require additional configuration.

What is exactly once delivery?

As its name suggests, exactly-once semantics means that each message is delivered precisely once. The message can neither be lost nor delivered twice (or more times). Exactly-once is by far the most dependable message delivery guarantee.

What is at least once delivery?

In case of failures that lead to message loss or take too long to recover from, messages are retransmitted to assure they are delivered at least once.

What is exactly once fault tolerance?

Fault tolerance means restoration to the states before the faults. There are three ways to guarantee the consistency in the fault tolerance of stream computing: Exactly once, At least once, and At most once. Exactly once means that each event affects the state only once.


2 Answers

In cases of at most once semantics, request is sent again in case of failure, but request is filtered on the server for duplicates.

In exactly once semantics, request is sent again, request is filtered for duplicate and there is a guarantee for the server to restart after failure and start processing requests from where it crashed.

But exactly once is not realizable because what happens when client sends request, and before it reaches the server, server crashes. There is no way of tracking the request.

http://de.wikipedia.org/wiki/Remote_Procedure_Call#Fehlersemantik

like image 33
Kahn Avatar answered Oct 07 '22 20:10

Kahn


Here is a pretty good explanation of the different types of messaging semantics for your second question:

At-most-once semantics: The easiest type of semantics to achieve, from an engineering complexity perspective, since it can be done in a fire-and-forget way. There's rarely any need for the components of the system to be stateful. While it's the easiest to achieve, at-most-once is also the least desirable type of messaging semantics. It provides no absolute message delivery guarantees since each message is delivered once (best case scenario) or not at all.

At-least-once semantics: This is an improvement on at-most-once semantics. There might be multiple attempts at delivering a message, so at least one attempt is successful. In other words, there's a chance messages may be duplicated, but they can't be lost. While not ideal as a system-wide characteristic, at-least-once semantics are good enough for use cases where duplication of data is of little concern or scenarios where deduplication is possible on the consumer side.

Exactly-once semantics: The ultimate message delivery guarantee and the optimal choice in terms of data integrity. As its name suggests, exactly-once semantics means that each message is delivered precisely once. The message can neither be lost nor delivered twice (or more times). Exactly-once is by far the most dependable message delivery guarantee. It’s also the hardest to achieve.

High-level overview of message delivery semantics

That's all part of this blog post about Exactly-once message processing (Disclosure: I work for Ably)

Hope this helps 😄

like image 136
Ramiro Nuñez Dosio Avatar answered Oct 07 '22 21:10

Ramiro Nuñez Dosio