编程知识 cdmana.com

The role of Apache zookeeper - observer and its difference with follow


 Insert picture description here

Pre

stay ZooKeeper In the process of cluster service running ,Follow The server is mainly responsible for handling non transactional requests from the client , Most of them deal with the query session and other requests initiated by the client . And in the ZooKeeper In the cluster ,Leader When the server fails , Will be in Follow Voting between cluster servers , Finally, one was elected Follow Server as new Leader The server .

except Leader and Follow The server ,ZooKeeper There is another one in the cluster Observer The server . stay ZooKeeper In the cluster ,Observer The server improves the whole ZooKeeper The performance of cluster operation plays an important role .


Observer Introduce

stay ZooKeeper In the process of cluster service running ,Observer The server and Follow The server has the same function , That's it Responsible for processing non transactional session request operations from clients such as querying data nodes . But with Follow The server is different from ,Observer No participation Leader The election work of the server , And will not be elected as Leader The server .


We put Follow The server and Observer Servers are collectively referred to as Learner The server .

Observer What the server does is almost the same as Follow The server is the same , So why ZooKeeper And create a Observer The role server ?

 Insert picture description here

Trying to explain the problem , It's from ZooKeeper The development of technology , One of the earliest ZooKeeper The frame is shown in the following figure , You can see , There is no such thing as Observer Server's .

 Insert picture description here
Early ZooKeeper In the process of cluster service running , Only Leader The server and Follow The server .

But as the ZooKeeper It is widely used in distributed environment , The design flaws of the early patterns also arise , The main problems are as follows :

  1. As the size of the cluster grows , On the contrary, the performance of cluster processing write is reduced .

  2. ZooKeeper Cluster cannot be deployed across domains

The main problem is , When ZooKeeper The size of the cluster is getting bigger , In the cluster Follow When the number of servers is increasing ,ZooKeeper The performance of transaction request operations such as creating data nodes will gradually decline . This is because ZooKeeper When a cluster processes transactional request operations , To be in ZooKeeper Vote on the transactional request in the cluster , Only more than half of them Follow The server voted unanimously , The write operation will be executed .

Because of this , With the cluster Follow There are more and more servers , Voting for a write and other related operations becomes more and more complicated , also Follow Network communication between servers is becoming more and more time-consuming , Cause to follow Follow Gradually increase the number of servers , Transactional processing performance is getting worse and worse .

To solve this problem , ZooKeeper A new server role has been created in the cluster , namely Observer—— Observer role server .Observer Can handle ZooKeeper Non transactional requests in the cluster , And not participate in Leader Nodes and other voting related operations . This ensures ZooKeeper Scalability of cluster performance , It also avoids the influence of too many servers participating in voting related operations ZooKeeper The ability of a cluster to handle transactional session requests .

In the introduction of Observer After the role server , One ZooKeeper Cluster service deployment Topology , As shown in the figure below :

 Insert picture description here
In actual deployment , because Observer No participation Leader Node and other operations , It's not like Follow The server is so frequent with Leader The server communicates . therefore , Can be Observer Servers are deployed in different network segments , It won't affect the whole ZooKeeper Cluster performance , It's called cross domain deployment .


The source code parsing

 Insert picture description here

版权声明
本文为[Little craftsman]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201225043318258s.html

Scroll to Top