Error message here!

Hide Error message here!

忘记密码?

Error message here!

请输入正确邮箱

Hide Error message here!

密码丢失?请输入您的电子邮件地址。您将收到一个重设密码链接。

Error message here!

返回登录

Close

My understanding of the registry

Mr. Xiaobai 2021-01-14 20:48:46 阅读数:8 评论数:0 点赞数:0 收藏数:0

In monomer applications , All in one application , But as the business grows , The functions of the system gradually become huge , Monomer application in development 、 Deployment and other aspects of efficiency is gradually low , It's getting more and more difficult to develop collaboration , Problems, etc. . therefore , It is necessary to split the system .

But in the microservices architecture , More and more services are being split up , The calling relationship between the whole system will become more and more complex , Each service management will become more and more difficult . Well, there's a lot of this 、 How to manage a system with complex dependencies becomes a problem .

At this time, we need a registry for service governance .


What is a registry

First , In the microservices architecture , What is a registry ?

A picture to summarize , It's an address book :

It stores the information of each service , And then provide it to those in need , At the same time, maintain all kinds of expired content .


Principle of Registration Center

In microservices , There are three very important roles : Registry Center 、 Service providers 、 Serving consumers . The correspondence is as follows :

The corresponding process is as follows :

  • Each service startup information is registered in the registry , The registry stores registration data .
  • After successful registration of each service , Upload service health information to the registration center to keep alive .
  • Each service consumer subscribes service information to the registry when it starts , Get service address list , The registry synchronizes to service subscribers when the service list changes .
  • Each service consumer invokes the service provider .

Registry functions

According to the information in the picture above , The functions of the registry are listed as follows :

  • Service registry : The core function of the registry , Record the information of each service provider , Such as service name 、IP、 Port, etc . Maintain service subscriber information .
  • Service registration 、 Logout interface : For service providers to register and cancel services .
  • Health check and service removal : Provide health information reporting interface , For registration service to upload health information to keep service alive . At the same time, the invalid nodes can be removed in time and synchronized to the service subscribers .
  • Service subscription and change notification : For service consumers .

Registry implementation mechanism

There are two modes of service registration : Self registration mode 、 Third party registration mode .

Self registration mode

Each service registers and cancels itself from the registry , At the same time, upload health information to the registration center to keep the registration valid .

  • advantage : The implementation is simple , No additional components need to be deployed .

  • shortcoming : The coupling degree is high , The server needs to adapt to the registry .

Third party registration mode

Each service instance does not need to register and log out directly to the registry itself , And you don't need to pay attention to your health information , These things are done directly by third-party components .

  • advantage : Services and registries are decoupled , There is no need for services to be adapted according to the registry .

  • shortcoming : Third party components need to be highly available , The introduction of third-party services also increases the complexity of the system .

Copyright statement
In this paper,the author:[Mr. Xiaobai],Reprint please bring the original link, thank you