by BehindJava
What is a Service Discovery and how is it implemented in the Microservices
In this tutorial, we are going to learn about Service Discovery and its implementation in Microservices, which is a very important question in the interview room.
Service Discovery
- Service Discovery is used to find where is the network location of that service, including IP and DNS name, to make a point to point connection.
- Service discovery is needed because in the cloud, i.e., Amazon Web Services have dynamic IP’s and DNS names.
-
Service instances, i.e., (virtual machines or containers) register or write their IP or DNS name into a container called service registry.
- You can think of service registry as a table in a database that has two columns.
- One column is the name of the microservices and Another column is the IP address of the instance.
- And you may have multiple roles in that table with the same microservice name, but with different IP’s.
- Service registry is a list of key value pair.
There are two ways of performing service discovery.