Microservices. What is difference between Service registry and service discovery

t;dr: Service Discovery is used when the client doesn't know what service they want at first, so they start by asking for a list of services that are available.

Disclaimer: I suspect that the term is used in different ways by different systems. So take the textbook answer I give here with a grain of salt.


In general, service registry systems follow a Broker Pattern (or something similar), and fall into two categories:

  1. White-pages brokering: clients know exactly what service they're looking for and ask for it by name

  2. Yellow-pages brokering: clients know what kind of service they need performed, but they don't know the exact service that they want

Both systems connect clients to services, and both involve services that use a Register Pattern to enter themselves into the registry.

But yellow-pages systems require a preliminary Service Discovery step. In the Service Discovery pattern,

  • The client first asks for a list of services from the broker.
  • The client selects a service from the list.
  • The client requests a connection to a service from the list.

Diagram from Gomaa

Image source: Hasan Gomaa, Software Modeling & Design (Cambriduge University Press, 2011), p. 283.


End to end process of registering services to a central place and reaching out to target service using service registry is service discovery.

This is pretty much like using DNS for finding IP address of a site and then reaching that site using the IP address.

I am a user of Kubernetes and it also talks on similar lines: https://kubernetes.io/docs/concepts/services-networking/service/#discovering-services

In short, service discovery is not a module with the specific role but the steps involved in connecting from serviceA to serviceB end-to-end.