[Translation] Microservice Design Pattern-8. Service Discovery-Third Party Registration

Original address: https://microservices.io/patterns/self-registration.html

background

Assuming that you use client-side service discovery or server-side service discovery, you need to register an instance with the registry when the service is started, and log out of the registry when it is closed, so that other services can be aware of it.

problem

How to register or cancel a service instance with the registry?

Considerations

  • The service must register an instance with the registry when it starts, and unregister the instance in the registry when it is shut down
  • The crashed service instance must be unregistered from the registry
  • Instances that are running but cannot provide services normally also need to be deregistered in the registry

solution

Introduce a third-party registration agent , responsible for the registration and cancellation of service instances in the service registry. When the service instance starts, the registration agent registers the instance to the registry. When the service instance is closed, the registration agent is responsible for unregistering the instance.

For example

Examples of third-party registration models include:

Result analysis

The benefits of the third-party registration model include:

  • Code services from registration mode than easier , because it is not responsible for registration
  • The registration agent can perform health checks on service instances and register/deregister instances based on their health status.

There are also some disadvantages:

  • The registration agent only has a vague understanding of the status of the service instance, such as only UP and DOWN, so it may not know whether it can process the request normally . Some Netflix Prana such as the above-mentioned registered agent using the health check to determine the availability of the service instance.
  • The need for additional maintenance of a registered agent services, and require high availability.

Related patterns

  • Registry -the core of service discovery
  • Client Service Discovery and server-side service discovery
  • Microservice basic framework -general microservice basic framework has self-registration function implementation
  • Self-registration -another alternative design pattern

Guess you like

Origin blog.51cto.com/11418075/2663789