What is an RPC framework?

What is RPC?

RPC framework, the whole process of Remote Procedure Call

In layman's terms, it is literallya remote procedure call, of course, this is just a definition, the specific implementation has the following four roles

  • registry - The registry, when the service provider starts, it will register with the registry, and then the registry will inform all consumers that there is a new service provider.
  • provider - The service provider, the consumer in the remote call process.
  • consumer - the service consumer, the consumer in the remote call process.
  • monitor - Monitor, which is mainly responsible for statistics of service consumption and invocation.

Evolution

  • For example, now A provides a service and tells other people: Now I have a method here. After calling, you can know the recipe of Hu La Tang, but when calling, you must provide your mobile phone number and name to let me know who you are. Then B heard: OK, I'll create the method to call now. At this time, two roles are created, provider (service provider refers to A) and consumer (service consumer refers to B) . This is the simplest remote call.

insert image description here

  • Now A suddenly issued a statement saying: I have now moved, and the new address is at xxx.xxx.xxx.xx. B is going to modify the code, modify the address, and then re-run the program. Then B thought, can I encapsulate the code of defining his address and calling his action, and then I don't need to move all the places when I modify it later. At this time, encapsulation is used to extract the underlying calling logic without seeing it every time.

insert image description here

  • After a while, A released a statement saying: I now have the recipe for fried dough sticks, and you can call another method to get it. Then B thought, you have one more method, I have to encapsulate a calling logic for each additional method, can we share a calling logic? can! Abstract the calling logic, make a proxy mode, and tell it about the remote method every time it is called. Can't we not touch this logic?

insert image description here

This forms a simple framework, of course, there are many more extending down

  • So what if other users call the method, can these methods be put in a fixed place, and then anyone can call them. This is the registry . When the service provider starts, it will register with the registry, and then the registry will inform all consumers that there is a new service provider.
  • What should I do if the service suddenly disappears when it is called? Can you monitor the service status and inform consumers in advance when there is a problem? This is the monitor , which is mainly responsible for statistics on the consumption and invocation of services.

There are also some communication protocols between these centers. The most basic is the TCP/IP protocol, which is also the most effective and not outdated protocol. Like the HTTP protocol, it is a protocol based on TCP/IP upgrade. It is implemented by transmitting JSON strings through URLs, which is more efficient than web serivce.

frame

Now the mainstream frameworks are Dubbo, Spring Cloud, etc., Motan used inside Weibo, and Tars used inside Tencent.

Guess you like

Origin blog.csdn.net/weixin_45525272/article/details/123576983