Dubbo recommends using zookeeper as the registry for the service.
1. The role of zookeeper: Zookeeper is used to register services and load balancing, which service is provided by which machine is required to let the caller know, simply, the corresponding relationship between the IP address and the service name. Of course, this correspondence can be implemented in the caller's business code in a hard-coded way, but if the machine that provides the service hangs up, the caller cannot know, and if the code is not changed, it will continue to request services from the suspended machine. Zookeeper can detect a hung machine and remove the IP and service correspondence from the list by beating the heartbeat mechanism. As for the support for high concurrency, it is simply scale-out to increase the computational power by adding machines without changing the code. By adding a new machine to the Zookeeper Registry service, the service provider has more customers to serve.
2. Dubbo:
is a tool for managing the middle tier, with a very multi-service access and service provider that needs to be dispatched between the business layer and the Data Warehouse, Dubbo provides a framework to address this problem.
Note Here The Dubbo is just a frame, as for what you put on the shelf is entirely up to you, like a car skeleton, you need to match your wheel engine. In this framework to complete the scheduling must have a distributed registry, storage of all the metadata of the service, you can use ZK, can also use other, but we all use ZK.
3. Zookeeper and Dubbo relationship:
Dubbo The registry is abstracted, it is possible to add different storage media to the registry to provide services, There are zookeeper,memcached,redis and so on.
introduced zookeeper as a storage medium, and introduced the features of zookeeper. First, load balancing, the single registration center's load-carrying capacity is limited, in the flow to a certain extent, the need to shunt, load balancing is to shunt and exist, a zookeeper group with the corresponding Web application can easily achieve load balancing; Resource synchronization, load balancing alone is not enough, The data and resources between the nodes need to be synchronized, the zookeeper cluster naturally has such function, naming service, the tree structure is used to maintain the global service address list, when the service provider starts, it/dubbo/${servicename}/to the specified node on ZK. Providers directory to write its own URL address, this operation has completed the release of the service. Other features include mast elections, distributed locks, and more.