Service discovery is a process used in microservice architecture to allow the various services to find and communicate with each other.
Example tools used for this are Consul, Etcd. These essentially act as a key-value store for microservices. Another tool is Zookeper, that works similarly to the other two.
How It Works
-
Service Registration - When a service starts, it communicates to the Service Discovery tool its address and port.
-
When a service wants to connect to another service, it reaches out to the Service Discovery tool with the service’s name to get its IP and port.
-
Services typically provide a health endpoint e.g.,
/health
to allow the Service Discovery tool to perform health checks on it.