by BehindJava
What is Client side Service Discovery in the Microservices
In this tutorial, we are going to learn about Client side Service Discovery in the Microservices.
Client side service discovery
-
The client service, or the service that is making the API call, is responsible for discovering the network location of the services and load balance across them.
- For example, you may find four instances of payments microservices.
- When client microservices has to load balance, which means that every time it sends the API call to a different instance, services register that IP’s or DNS name. When they start up and IP of a service is removed using a heartbeat mechanism.
- Heartbeat mechanism means that you send an API call to a specific endpoint. If you don’t get an HTTP status 200 back, you know that a microservice is down or not healthy, and then we remove it from the service registry.
- In client side service discovery, there is no load balancer required.
- If you look at the below image, you have the client microservices that is trying to make an API call on the right side, where we have three instances of a given microservice.
- Assume payment microservices, when a new instance comes to life, they register their IP in the service registry and the client microservices looks up to service registry.
- It finds the three IP addresses when it wants to make an API call to that microservices uses one of those IP’s.