Service registry

Microservices are independent, but many use cases will need them to be interdependent. This means for some services to work properly they need data from another service, which in turn may or may not depend on other services or sources.

For example, our pricing service will directly depend on the demand service, which in turn depends on the inventory service. But these three services are completely independent, that is they can be deployed on any host, port, or location and scaled at will.

If the pricing service wants to communicate with the demand service, it has to know the exact location to which it can send requests to get the required information. Similarly, the demand service should know about the inventory service's details in order to communicate.

So we need a service registry that registers all other services and their locations. All services should register themselves to this registry service when the service is started and deregister itself when the service goes down.

The service registry should act as a database of services, recording all the available instances and their details.