Home  >  Article  >  What is the relationship between dubbo and zookeeper?

What is the relationship between dubbo and zookeeper?

青灯夜游
青灯夜游Original
2020-04-16 17:03:235338browse

What is the relationship between dubbo and zookeeper? The following article will introduce to you the relationship between dubbo and zookeeper. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

What is the relationship between dubbo and zookeeper?

Dubbo recommends using Zookeeper as the service registration center.

1. The role of Zookeeper:

zookeeper is used to register services and perform load balancing. Which service is provided by which machine must be known to the caller. Simple In other words, it is the correspondence between the IP address and the service name. Of course, this correspondence can also be implemented in the caller's business code through hard coding. However, if the machine that provides the service hangs up, the caller has no way of knowing. If the code is not changed, it will continue to request the dead machine to provide services. Zookeeper can detect the hung machine through the heartbeat mechanism and delete the corresponding relationship between the IP and service of the hung machine from the list. As for supporting high concurrency, simply speaking, it means horizontal expansion, increasing computing power by adding machines without changing the code. By adding new machines to register services with ZooKeeper, the more service providers there are, the more customers they can serve.

2. The role of dubbo:

Dubbo is a tool for managing the middle layer. There are many services between the business layer and the data warehouse. Service providers need scheduling, and dubbo provides a framework to solve this problem.

Note that the dubbo here is just a frame. What you put on the shelf is completely up to you, just like a car skeleton, you need to match your wheel engine. To complete the scheduling in this framework, there must be a distributed registration center to store the metadata of all services. You can use zk or others, but everyone uses zk.

3. The relationship between zookeeper and dubbo:

Dubbo abstracts the registration center so that it can connect to different storage media to provide services to the registration center. The introduction of zookeeper as a storage medium also introduces the features of zookeeper.

  • The first is load balancing: the carrying capacity of a single registration center is limited. When the traffic reaches a certain level, it needs to be diverted. Load balancing exists for the purpose of diverting traffic. A zookeeper cluster cooperates The corresponding web application can easily achieve load balancing;

  • Resource synchronization: load balancing alone is not enough, the data and resources between nodes need to be synchronized, and the zookeeper cluster naturally has Such a function;

  • Naming service: uses a tree structure to maintain a global service address list. When the service provider starts, it writes to the specified node directory on zookeeper. own URL address, this operation completes the release of the service

  • Mast: ZooKeeper can ensure that the client cannot create an existing ZNode. That is to say, if multiple clients request to create the same temporary node at the same time, only one client request will be successfully created in the end. Using this feature, you can easily conduct Master election in a distributed environment.

  • Distributed lock: Distributed lock is a way to control synchronous access to shared resources between distributed systems. If the client machine that currently obtains the lock crashes or restarts, the temporary node will be deleted and the lock will be released. After the business logic is executed normally, the client will actively delete the temporary node it created and release the lock.

For more related knowledge, please pay attention to PHP Chinese website! !

The above is the detailed content of What is the relationship between dubbo and zookeeper?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn