what's the situation? A Java programmer who has worked for 5 years, can't answer this question?
"How does Dubbo dynamically sense service offline"?
Well, for this question, look at the answers of ordinary people and experts!
Ordinary people:
Ok. . . . . . . . . . . .
Expert:
Ok, interviewer, I will answer this question from several aspects.
First of all, Dubbo uses Zookeeper by default to realize service registration and service discovery. In short, it is the communication address between multiple Dubbo services, which is maintained by Zookeeper.
On Zookeeper, a tree structure is used to maintain the protocol address of the Dubbo service provider
The Dubbo service consumer will look up the address list of the target service from the Zookeeper Server, so as to complete the service registration and consumption functions.
Zookeeper will use the heartbeat detection mechanism to judge the running status of the Dubbo service provider to decide whether the service should be removed from the address list.
When the Dubbo service provider fails, Zookeeper removes the address of this service,
Then the Dubbo service consumer needs to perceive the change of the address, so as to avoid subsequent requests being sent to the faulty node, resulting in request failure.
That is to say, Dubbo needs to provide the dynamic perception ability of service offline.
This capability is achieved through the Watch mechanism provided in Zookeeper
To put it simply, the Dubbo service consumer will use the Watch in Zookeeper to register and monitor the /providers
node registration and monitoring of the Zookeeper Server.
Once the child node under this node changes, Zookeeper Server will send an event to notify Dubbo Client.
After the Dubbo client receives the event, it will delete the service address in the local cache, so that the request will not be sent to the failed node in the future to complete the service offline awareness.
The above is my understanding of the problem!
Summarize:
Dubbo is currently a very mainstream open source RPC framework, which is used in many enterprises.
It is necessary to understand the underlying working principle of this RPC, which can help developers improve the efficiency of solving development problems.
Still want to say one more thing, in the position of Java, if you want to go further, you must work hard.
This issue of ordinary people VS master interview series ends here.
If you have any technical interview questions that you don't understand, please feel free to private message me at any time.
Copyright notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated. Please indicate the source forMic带你学架构
!
If this article is helpful to you, please help to follow and like, your persistence is the driving force for my continuous creation. Welcome to follow the WeChat public account of the same name to get more technical dry goods!
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。