Quorom mechanism is a kind of voting algorithm commonly used in distributed system to ensure data redundancy and eventual consistency, and its main mathematical idea comes from pigeon nest principle.
What is the pigeon nest principle?
One of the simple representations is:
If there are n cages and n+1 pigeons, all pigeons are kept in pigeon cages, then at least one cage has at least 2 pigeons.
The other is:
If there are n cages and kn+1 pigeons, all pigeons are kept in the pigeon cage, then at least one cage has at least k+1 pigeons.
Well, it's familiar.
Distributed systems typically support multiple replicas, which are stored on different nodes and require multiple copies to be manipulated when read and written. Given the consistency issue, you can update all replicas in a write operation, while reading one copy at a time. However, this write load is too heavy, reading is easy, read and write load is obviously unbalanced.
With the quorum mechanism, the write operation needs to be completed immediately the number of copies reduced, read operation needs to read the number of copies of the increase, to a certain extent balanced read and write two operations, the overall performance of the system will be improved. For example, there are 5 copies that allow the write operation to return as soon as 3 is written. The rest is done in slow synchronization within the system. Read operations require at least 3 reads to ensure that at least one of the latest data can be read. (Pigeon nest principle)
This protocol has three key values N, R, and W:
n indicates the number of replicas that the data has.
R indicates the minimum number of copies that need to be read to complete the read operation.
W indicates the minimum number of copies to write to complete the write operation.
In this strategy, only the R + W > N is guaranteed to provide strong consistency, because the nodes that read the data and the nodes that are synchronously written have overlapping (pigeon nest principle).
For example: n=3,w=2,r=2, it means that the data in the system has 3 different replicas, when the write operation, it is necessary to wait for at least 2 copies completed the write operating system will return the execution of the successful state, for the read operation, the system has the same characteristics. Because of R + W > N, the system is guaranteed to be strong consistent.
The read (write) delay in the NWR model is determined by the slowest R (W) copy, sometimes in order to achieve higher performance and lower latency, r and W and possibly less than n, then the system cannot guarantee that the read operation can obtain the latest data.
If R + w≤n, then the read and write operations are not overlapping, the system can only guarantee eventual consistency, and the consistent time of the replica depends on the implementation of the system asynchronous update, the time period of the inconsistency is equal to the time from the beginning of the update to all the nodes are asynchronous completion of the update between.
Here are a few special cases for different settings.
When w = 1,r = N, the system has higher requirements for write operations, but the read operation is slower, and if there are nodes in N nodes fail, the read operation will not be completed.
When r = 1,w = N, the system requires high performance, high availability of read operations, but low write performance for systems that require a large amount of read operations, and if nodes in N nodes fail, the write operation cannot be completed.
When R = W = N/2 + 1 o'clock, the system balances read and write performance, taking into account performance and availability, the default setting for the Dynamo system is the n=3,w=2,r=2.
For the NWR model, there is the issue of version conflict, and for this reason, Amazon's Dynamo introduced the Vector Clock, which is discussed next time.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
QUORUM/NRW mechanism