background
In the case of Client Service discovery mode or server-side service discovery mode, each service instance must be registered to the service registry at startup to ensure that it can be acquired and log off at shutdown.
problem
How to register and unregister service instances within the service registry.
requirements Each service instance must be registered to the service registry at startup and logged off when it is closed. The service instance that crashed must be unregistered from the service registry. The service instance that is running but unable to process the request must be logged off from the service registry.
Programme
A service instance must be automatically registered to the service registry. At startup, the service instance registers itself (host and IP address) with the service registry so that it can be discovered. The client must periodically update its registration information to ensure that the Registry is aware that it is still in a running state. When off, the service instance is automatically logged out from the service registry.
This process is typically implemented by a MicroServices chassis framework.
Example
Netflix Eureka is an example of a service registration form. It provides a registration API and a set of client libraries for service implementation autoenrollment (logoff).
When using Apache zookeeper as the service registry, each service corresponds to a specific zookeeper Znode. At startup, each service instance creates a sub-znode with a short-lived time under the service's Znode. The child Znode contains the location information for the instance. The service client can determine the availability of the corresponding service instance by retrieving the sub-znode of the service. If the service instance terminates but the corresponding child znode,zookeeper is not removed, it will be removed after the child Znode's survival time expires.
Result Background
The advantage of the self-registration mode is that the service instance knows its state, so it can implement a more complex state model than start/stop, such as startup, availability ...
But the self-registration model also has the following drawbacks: coupling services with the service registry. The service registration logic needs to be implemented for each programming language/framework used to write the service, such as Node.js/javascript, Java/scala, and so on. Service instances that are still running but are unable to process the request typically do not automatically log off in the service registry.
Correlation Mode Service registry-an important part of the service discovery mechanism. Client Discovery-One of the ways that service instances are discovered. Server-side Discovery-another way that service instances are discovered. MicroServices Chassis-MicroServices chassis framework is responsible for implementing self-registering functions. Third-party registrations are alternatives.
Original link