How to design a RPC framework like Dubbo?
You have to go to the registry to register your service. Do you have to have a registry to keep information about each service? Zookeeper can do that, right? Then your consumer needs to go to the registry to get the service information, right, and each service may exist on multiple machines. Then it’s time for you to make a request. How? Based on dynamic proxies, of course, you get a dynamic proxy for the interface, which is a local proxy for the interface, and then the proxy finds the machine address of the service. Which machine do you find to send the request to? You’d have to have a load balancing algorithm, like the simplest one that polls randomly. Then find a machine and send a request to it. The first question is how to send it? You could say netty, NIO; The second question is what format of data to send? You could say hessian serialization protocol, or whatever, right? Then the request passed. On the server side, you need to generate a dynamic proxy for your own service, listen on a network port, and then proxy your local service code. When the request is received, the corresponding service code is called, right?