Redundant Microservice Registries: Load Balancing and Service Discovery Benefits
Automatic load balancing and the automatic discovery of microservices are vital features on
To mitigate this risk, we've implemented redundancy in the microservice registry. Multiple instances of the registry can be installed on different nodes. When a microservice registers or deregisters, all other registry instances are notified. If a new registry instance is added, it synchronizes with the existing entries of registered microservices.
Microservice registries broadcast their presence to all nodes upon startup. Any new nodes added to the system will also be informed of these registries.
Local Microservice Helper Services
To simplify the registration of microservices, a local helper plugin is installed on each node. These helper services gather information about available registries.
When a locally installed service needs a microservice registry (e.g., to send a message to an unidentified microservice), the system prompts the helper for a registry. The helper then locates the closest registry, leveraging the knowledge of the router service, which is familiar with the entire network. This ensures the message reaches the appropriate registry.
If a microservice is set up during a node`s boot-up, local knowledge of microservice registries might not exist yet. But, the helper still processes the registration data. When a registry`s broadcast is detected, the helper completes the registration for the local microservice. This ensures no delays while waiting for broadcasts.
The Helper can also offer lists of microservice registries and supports a listener pattern, notifying interested parties when registries are added or removed.
Sending Messages to Microservices
Microservices are distinguished by an ID, which can be numeric, a string, or a UUID.
Sending messages to a microservice is straightforward. Only the microservice's ID needs to be included in the message envelope, and the system handles the rest.
If multiple instances of a microservice exist, the system selects one (ensuring load balancing).
If a response is desired (commonly the case), the response envelope will also contain the direct address of the microservice. Senders can use this address to communicate directly with the microservice, bypassing the registry. If any issues arise (e.g., the microservice's node shuts down), the sender can revert to using a registry.