( If it helps , Please give me some suggestions , Add the attention , thank you ! Your support is the driving force for me to keep updating my articles . This blog will gradually launch a series of large website architecture 、 distributed application 、 Design patterns 、 Architecture pattern and so on )

Zookeeper yes Hadoop Next sub project , It's a reliable coordination system for large distributed systems , The functions provided include naming services 、 Configuration maintenance 、 Distributed synchronization 、 Cluster services, etc .

Zookeeper It can be replicated in clusters , Through clusters Zab(Zookeeper Atomic Broadcast) Protocol to keep data consistent .

Stages :leader election Phase and Actomic broadcast Stage . The cluster will elect a leader, Other machines are called follower, All writes are sent to leader, And pass broadcast Tell... All the updates follower. When leader Collapse or leader Lose most of follower when , A new... Needs to be re elected leader, Restore all servers to the correct state . When leader To be elected , And most of the servers complete and leader After state synchronization of ,leader election The process is over , Will enter the Atomic broadcast The process of .Actomic broadcast Sync leader and follower Information between , Guarantee leader and follower Have the same system state .

Zookeeper The structure of the cluster is as follows :

Implementation of routing and load balancing

When the service is more and more , When it gets bigger and bigger , The number of corresponding machines is also increasing , The configuration information of service and address is managed and maintained manually , It's getting more and more difficult . also , Rely on a single hardware load balancing device or use LVS、Nginx And other software solutions for routing and load balancing scheduling , The problem of single point of failure also began to highlight , Once the service routing or load balancing server goes down , All services that depend on it will fail . If we adopt the deployment scheme of dual high availability , Using a server “stand by”, Part of the solution , But given the high cost of load balancing devices , It is difficult to popularize it in an all-round way .

Once the server and ZooKeeper Cluster disconnect , Nodes don't exist , By registering the corresponding watcher, Service consumers can know the change of service provider's machine information in the first time . Use it znode The characteristics and the watcher Mechanism , Use it as a configuration center for dynamic registration and access to service information , Unified management service name and its corresponding server list information , We can sense the state of the back-end servers in near real time ( go online 、 Offline 、 Downtime ).Zookeeper Through clusters Zab agreement , Service configuration information can be consistent , and Zookeeper Its fault tolerance and leader The election mechanism , It can ensure that we can easily expand the capacity .

Zookeeper in , The service provider at startup , Name of the service it provides 、 Server address 、 Register to the service configuration center as a node , The service consumer obtains the machine list node under the service name node to be called through the service configuration center . Through the load balancing algorithm described above , Select one of the servers to call . When the server is down or offline , because znode Non persistent features , The corresponding machine can be dynamically removed from the service configuration center , And trigger the watcher. In the process , The service consumer only needs to query the service configuration center when invoking the service for the first time , Then cache the queried service information to the local , Later calls directly use the locally cached service address list information , Instead of sending a request to the service configuration center to get the corresponding service address list , Until the address list of the service changes ( Machine online or offline ), The change will trigger the corresponding watcher Re query the service address . This decentralized structure , Make the service consumer when the service information has not changed , Almost independent of configuration center , It solves the problem of single point fault caused by load balancing equipment before , And greatly reduces the pressure of the service configuration center .

adopt Zookeeper To achieve dynamic service registration 、 The dynamic perception of machine online and offline , The expansion is convenient , Fault tolerance is good. , And no centralized structure can solve the problem of single point of failure caused by the previous use of load balancing equipment . Only when the configuration information is updated will the service consumer go Zookeeper Get the latest service address list on , You can use local cache at other times , In this way, when the service information has not changed , Almost independent of configuration center , It can greatly reduce the pressure of the configuration center .

Zookeeper More articles on the core mechanism

  1. zookeeper Internal mechanism learning

    zookeeper Internal mechanism learning 1. zk The design goal of Final consistency :client No matter which one you connect to Server, It's all shown in the same view . reliability : Simple . robust . Good performance . If the news m Received by a server ...

  2. Learning notes :Zookeeper The election mechanism

    1.Zookeeper The election mechanism Zookeeper Although not specified in the configuration file master and slave however ,zookeeper Working hours , There is a node for leader, Others are follower Leader ...

  3. zookeeper Comprehensive analysis of core principles

    Each of the following zookeeper The mechanism java Client practice reference zookeeper java The client side curator Detailed explanation . Official documents http://zookeeper.apache.org/doc/current/z ...

  4. Zookeeper The election mechanism ( turn )

    Source :http://blog.csdn.net/tototuzuoquan/article/details/54426684 1.Zookeeper The election mechanism Zookeeper Although not specified in the configuration file ...

  5. zookeeper Carding of heartbeat mechanism process

    zookeeper Carding of heartbeat mechanism process Processor chain Chain protected void setupRequestProcessors() { RequestProcessor finalPr ...

  6. JAVA The two core mechanisms of the foundation

    All of a sudden you need to learn Java, I've long forgotten what I learned in school , It takes the shortest time to Java Straighten out the knowledge , The point is still J2EE, After all ava In the project 95% All are J2EE, It's better to start with the basics J2SE Let's learn ....... The first is to understand ...

  7. Spring Advanced road (1)-Spring The core mechanism : Dependency injection / Inversion of control

    Original address :http://blog.csdn.net/wangyang1354/article/details/50757098 We often come across a situation like this , That is, when we develop projects, we often call them in one class ...

  8. MFC The second of the six core mechanisms : Runtime type identification (RTTI)

    The last section was about MFC One of the six core mechanisms :MFC Initialization of the program , This section continues with MFC The second of the six core mechanisms : Runtime type identification (RTTI). typeid Operator Runtime type identification (RTTI) That is to say, we know that an object belongs to ...

  9. MFC One of the six core mechanisms :MFC Initialization of the program

    A lot of people who do software development have a spirit of getting to the bottom of things , For example, we have been using MFC, Very convenient , You can make all kinds of window programs without learning too much principle knowledge , But friends who like to study must want to know , What did Microsoft do for us , Let's put it in its frame ...

Random recommendation

  1. First time to know SpringMvc

    First time to know SpringMvc springMvc brief introduction :SpringMVC Also called Spring Web mvc, A framework that belongs to the presentation layer .Spring MVC yes Spring Part of the frame , Is in Spring3.0 Post release s ...

  2. JAVAScript Control multiple drop-down boxes

    Method : Get the array of multiple selection drop-down box objects → Circular judgement option Option selected attribute (true For the selection ,false For unselected )→ Use value Property to get the value of the selected item . An example is shown as follows : I checked this thing on Baidu , I'm here for ...

  3. Java Sorting algorithm —— Shell Sort

    package sort; //================================================= // File Name : ShellSort //------- ...

  4. build Android Development environment brief steps

    ( One ) install JDK JDK Download address http://www.oracle.com/technetwork/java/javase/downloads/index.html stay Linux The terminal enters the following command , set up ...

  5. Web Software security attack

  6. 【BZOJ-3555】 penguin QQ character string Hash

    3555: [Ctsc2014] penguin QQ Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 1545  Solved: 593[Submit][Statu ...

  7. [ turn ]LIBSVM-3.18 stay python Use in the environment

    http://blog.csdn.net/lj695242104/article/details/39500039 1) install Python, Go directly to the official website 2) function “cmd”, Direct input python, see ...

  8. 【SpringMVC】SpringMVC series 8 And Servlet API As the reference

    8.Servlet API As the reference 8.1. summary MVC Of Handler What methods can be accepted ServletAPI Parameters of type : HttpServletRequest HttpServletRes ...

  9. HTTP && socket

    http://blog.csdn.net/zeng622peng/article/details/5546384 1.TCP Connect The mobile phone can use the networking function because the bottom layer of the mobile phone has realized TCP/IP agreement , It can make the mobile terminal ...

  10. MyGeneration Database driver is empty

    Redo the system and install MyGeneration  But after the installation, we found that there was no driver information in the driver , Check the solution on the Internet, the following can be a perfect solution , Special note : The problem is because of multi ...