In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to use distributed Quorum NWR". In daily operation, I believe many people have doubts about how to use distributed Quorum NWR. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use distributed Quorum NWR". Next, please follow the editor to study!
How are the three alchemy furnaces distributed? "
Tai Bai Venus: Lao Jun, how do you distribute your gossip stove?
"Let's uncover Lao Jun's alchemy furnace and see how the six elixir are distributed.
First of all, it is easy to guess how Danlu alchemy is distributed:
No.1 Dan smelted two Yannian Dan.
No. 2 Dan furnace refines two Jianbudan.
No. 3 Dan smelting two recovery dans.
The situation of Dan furnace as thought by Taibai Venus
So what's wrong with this distribution?
Let's imagine that if the No. 1 Dan furnace explodes because the fire is too high, then the two Yannian Dan will fail. This is the same as putting eggs in one basket. If the basket is knocked over accidentally, all the eggs in it fall out and break.
"Mr. Tai: Lao Bai, I'll show you the lid of the boiler and you'll see."
No. 1 Dan furnace refines a Yanian Dan and a Jianbu Dan.
No. 2 Dan smelted one Yanian Dan and one recovery Dan.
No. 3 Dan furnace refines a Jianbu Dan and a recovery Dan.
Actual distribution of Dan furnace
"Taibai Venus: Lao Jun, why is it so distributed? the heat of each elixir is not so easy to control.
Lao Jun: Lao Bai, I am a master of alchemy, and the heat does not defeat me.
Taibai Venus: you are indeed an old gentleman, so that even if there is a problem with a Dan stove, at least one can be refined, not both will be destroyed. "
Mapping to our Internet system: Dan furnace is similar to a server node or database node, through multiple nodes to back up data to ensure the high availability of the system (High Availability).
Second, how to ensure the same quality of Dan medicine
2.1 consistency
"Taibai Venus: Lao Jun, you just mentioned that two Yannian Dan need to have the same effect and the same size?
Taishang Laojun: indeed, the quality of Dan medicine must be consistent. I practice all nine grades of Dan medicine, but the efficacy is very different. "
What on earth is going on with the consistency of the quality mentioned by Lao Jun?
How can the quality of Yannian Dan in No. 1 Dan furnace be consistent with that in No. 2 Dan furnace?
Isn't this what we often call distributed consistency? The two Dan medicines are distributed in different Dan stoves and need to ensure the same quality.
As shown in the following picture, the two Yannian Dan are big and small, and the color is also different, that is, the quality is different.
The quality is different.
In architecture design, such as requesting access to different databases, the data found is the same, which is consistency.
The following figure shows: the browser accesses data An in database 1 and database 2, and the result returns A = 1.
Consistency in distributed system
2.2 final consistency and strong consistency
Consistency in distribution can be divided into final consistency and strong consistency.
The so-called strong consistency means that after the write operation is completed, any subsequent access can read the updated value. This is the consistency and partition fault tolerance required by CP system.
How do you understand it when you put it in alchemy?
For example, Lao Jun added lotus to Yannian Dan of No. 1 Dan stove, and Yannian Dan of No. 2 Dan Furnace was also operated in the same way, so Lao Bai opened the furnace lid and saw that the ingredients of the two Yannian Dan were the same.
The ultimate consistency is that there is no guarantee that subsequent visits can read the updated value, but after a period of time, and then read, you can get the same value. In other words, during this period of time, old data may be read. This is the availability and partition fault tolerance required by AP systems.
How do you understand it by putting it in alchemy?
For example, Lao Jun added lotus flowers to Yannian Dan of No. 1 Dan Furnace, and it took an hour to add snow lotus to No. 2 Dan Furnace, so at this time, the ingredients of the two Yannian Dan are not the same. But after an hour, the final composition is the same.
Controllable quality: Quorum NWR protocol
"if Yannian Dan must ensure the strong consistency of quality, while Jianbudan only needs to ensure the final consistency of quality, how can this be controlled?
"this is not difficult for Lao Jun, because he knows the distributed protocol: Quorum NWR.
The meaning of the word Quorum: a quorum (of a meeting). Mainly look at the following three capital letters: n, W, R. Consistency is controlled by NWR.
3.1 Parameter N
Let's take a look at the situation in Dan furnace, the two Yannian Dan are backup to each other, which is equivalent to having two copies.
N is called replica number, also known as replication factor (Replication Factor). Indicates how many copies of the same data, so: n = 2 of Yannian Dan. And so on: n = 2 for Jianbudan and N = 2 for Fufangdan. As shown in the following figure:
The number of copies of Dan medicine is the same.
Can N be changed?
The following picture shows: for example, I want to refine 3 Yannian dyes, that is, every Dan furnace has Yannian Dan, then change N to 3. And Jianbudan only needs to refine one tablet is enough, that No.1 Dan furnace is fine, so N = 1.
The number of copies of multiple elixir is different.
3.2 Parameter W
After you specify the copy number N, you can read and write to the copy data.
Read operation: check the situation of Dan medicine in Dan furnace.
Write operation: add herbs to Dan medicine and raise the temperature.
Then how to read and write multiple elixir? For write operations, we have the W parameter, and for read operations, we have the R parameter.
W is called the write consistency level (Write Consistency Level), which means that W replica updates have been successfully completed before the write operation is completed.
For example, set the W = 2 of Yannian Dan, which means that when the write operation is performed on Yannian Dan, the write operation is completed only when the update of 2 copies is completed.
The following picture shows: Yannian Dan in No. 1 Dan Furnace and No. 2 Dan Furnace has joined the lotus flower, while the Yan Niandan Dan in the No. 3 Dan furnace has not joined the lotus flower. That is, only two copies have been updated, which meets the condition of W = 2, that is, the write operation is complete.
Two Yannian Dan joined the lotus flower
But did you find the problem? Yannian Dan of No. 3 Dan Furnace did not join Lotus, so how can you ensure that when you check the situation of Dan medicine, you will know that you have joined Lotus? That is, how to ensure the strong consistency of reading and writing, which will use the third parameter: R.
3.3 Parameter R
R, called read consistency level (Read Consistency Level), means that when you read a data object, you need to read R copies and then return the latest of the R copies.
Back to the question of alchemy, set the R = 2 of Yannian Dan, that is, when you check the situation of Yannian Dan, you only need to check the situation of Yannian Dan in the two furnaces, and then return to the latest situation of Yannian Dan.
Suppose you are looking at the Yannian Dan in the No. 1 and No. 2 Dan furnace, and the return is as follows: Lotus has been added. This scenario is consistent.
Suppose you are looking at the Yannian Dan in the No. 1 and No. 3 Dan furnace, the Yannian Dan in the No. 1 Dan furnace has joined the lotus, and the No. 3 Dan furnace has not joined the lotus, but the last operation time of the Yannian Dan in the No. 3 Dan furnace is earlier than that of the No. 1 Dan furnace. So return to the situation of Yannian Dan in No. 1 Dan furnace: Lotus has been added. This scenario is also consistent.
Through the above two scenarios, we know that by setting R = 2, even if we read the third piece of unupdated data, we can return the updated data and achieve strong consistency.
3.4 Parameter combination
Different combinations of parameters N, W and R will bring different consistency effects.
For example, in the above example, N = 3Magi W = 2Magi R = 2je W + R > N, for the client, the whole system can ensure strong consistency and must be able to return the updated data.
When W + R N, most nodes are successfully written, the success is returned to the client. (requires N greater than 2)
All:W = N, after all nodes are written successfully, success is returned.
In addition, for the temporal database InfluxDB, the read operation needs to read a large amount of data. In order to ensure the efficiency of reading, it does not support the read consistency level (R = N), but strong consistency can be achieved by setting the write consistency level to all.
InfluxDb implements Quorum NWR. When online business needs to make some temporary consistency adjustments, you can set different write consistency levels to complete fast switching.
At this point, the study on "how to use distributed Quorum NWR" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.