In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
How to analyze the principle of CAP and the ultimate consistency, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
In a football match, a player scores three goals in a game, which is called a Hat-trick. In distributed data systems, there is also a hat principle (CAP Theorem), but this hat is not the other hat. In the CAP principle, there are three elements:
Consistency (Consistency)
Availability (Availability)
Partition tolerance (Partition tolerance)
The CAP principle means that these three elements can only achieve two points at the same time, and it is impossible to take all three at the same time. Therefore, when designing a distributed architecture, a trade-off must be made. For distributed data systems, partition tolerance is a basic requirement, otherwise it will lose its value. Therefore, the design of distributed data system is to strike a balance between consistency and availability. For most web applications, there is no need for strong consistency, so sacrificing consistency for high availability is the direction of most distributed database products.
Of course, the sacrifice of consistency is not completely regardless of the consistency of the data, otherwise the data is chaotic, then there is no value no matter how high the availability of the system is distributed. Sacrifice consistency, but no longer require strong consistency in relational databases, but as long as the system can achieve the final consistency, taking into account the customer experience, this ultimate consistent time window should be as transparent to users as possible, that is, the need to ensure "user-perceived consistency". The high availability of the system and the ultimate consistency of the data are usually achieved through multiple asynchronous copies of data, and the time window of "user-perceived consistency" depends on the time when the data is replicated to a consistent state.
Final consistency (eventually consistent)
Consistency can be divided into two different perspectives: client-side and server-side. From the point of view of the client, consistency mainly refers to the problem of how to obtain the updated data during multiple concurrent access. From the point of view of the server, it is how to update how to replicate and distribute to the whole system to ensure that the data is ultimately consistent. Consistency is due to the problem of concurrent reading and writing, so when understanding the problem of consistency, we must pay attention to considering the scenario of concurrent reading and writing.
From the client point of view, when multi-process concurrent access, the updated data in different processes how to obtain different policies, determine the different consistency. For relational databases, it is required that the updated data can be seen by subsequent visits, which is highly consistent. If you can tolerate some or all of the subsequent access, it is weak consistency. If access to the updated data is required after a period of time, it is the ultimate consistency.
According to when and how each process accesses the data after updating the data, the final consistency can be divided into:
Consistency of cause and effect. If process A notifies process B that it has updated a data item, subsequent access to process B returns the updated value, and a write is guaranteed to replace the previous write. Access to process C that has no causal relationship with process A follows the general rule of final consistency.
"read what you write (read-your-writes)" consistency. When process A updates a data item itself, it always accesses the updated value and never sees the old value. This is a special case of the causal consistency model.
Session (Session) consistency. This is a practical version of the previous model, which puts the process accessing the storage system into the context of the session. As long as the session exists, the system ensures the consistency of "reading what you write". If the session is terminated due to some failure, a new session is established, and the system's guarantee does not extend to the new session.
Monotone (Monotonic) read consistency. If the process has already seen a value of the data object, any subsequent access will not return the value before that value.
Monotonous write consistency. The system ensures that writes from the same process are executed sequentially. If the system cannot guarantee this degree of consistency, it will be very difficult to program.
The above different ways of final consistency can be combined, such as monotonous read consistency and read-write consistency. And from a practical point of view, the combination of the two, reading their own updated data, and once reading the latest version will no longer read the old version, for program development on this architecture, there will be a lot less extra trouble.
From the server point of view, how to distribute the updated data to the whole system as soon as possible and reduce the time window to achieve the final consistency is a very important aspect to improve the availability of the system and user experience. For distributed data systems:
N-number of copies of data replication
W-the number of nodes that need to be written when updating data
R-number of nodes that need to be read when reading data
If WhirlR > N, the nodes written and read overlap, then it is highly consistent. For example, for a typical one-master-standby synchronous replication relational database, whether reading the data of the master database or the standby database, it is the same.
If W+R=3. Different combinations of NMagol and WPerry are to strike a balance between usability and consistency in order to adapt to different application scenarios.
If any one of the write nodes fails, the availability will be reduced, but because the N nodes of the data distribution are written synchronously, strong consistency can be guaranteed.
If the write performance and availability are relatively high, only one node is required to write successfully. However, the process of reading other nodes may not be able to get the updated data, so it is weak consistency. In this case, if W.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.