DWQA QuestionsCategory: DatabaseDoes zookeeper have only one leader node responsible for writing, is there any pressure?
Nisus asked 4 weeks ago
  1. Only the leader node is responsible for writing in zookeeper. Is there any pressure?
  2. How to read when reading? Is each follower node responsible for reading? How to ensure that the read data is the latest submitted? What if a certain follower node is not the latest data, but is read?
1 Answers
Then go hiking answered 4 weeks ago

First of all, most of the business, read than write operations, and the difference is not a little bit, but several orders of magnitude.
To put it bluntly, the number of times to add, modify and delete is far less than the number of queries, so the pressure of the node responsible for writing must be less than that of the node responsible for reading.
Secondly, the leader is not responsible for writing ZK, but the leader is responsible for notifying other followers to write. Each follower can also receive a write request, except that it does not execute the write first, but forwards it to the leader. After the leader notifies it to write, it starts to write. This is different from other read-write separation schemes. For example, read-only nodes with read-write separation in MySQL do not accept write requests at all.
Finally, ZK has half ack mechanism and Zab protocol to ensureStrong consistency on writeIn terms of reading, it is possible to read non up-to-date data, but it itself isMonotonous readingIn addition, the watch function is provided, so you can ensure thatFinal agreement
So what do you ask? Watch and read it again.
P. S. cap is generally used to ensure that AP and C are ultimately the same, and some even do not have C; CP also has. But if we want AP to be strong and consistent, there will be none.
P. S.p.s. ZK had some designs that were not reasonable in the end, but because of the historical burden such as compatibility, it can only do so. Consider using etcd, a rising star.

Nisus replied 4 weeks ago

Thanks! I know etcd some time. It seems etcd is better than zookeeper