Service Registry in Microservices
A database of all of the instances, services, their network addresses (IP, port combinations)
Self registry: Microservices register themselves to the service registry. When a service is scaled, the spawned service registers to the SR. Microservice regularly update the data by themselves. Registry itself removes unless it is new.
Thirdparty Registry: The service registry asks the services about new instances and services. Listens to autoscaling events to find out if new instances are being spawned.
Service Discovery in Microservices
SR keeps records of the services and addresses. The client can query the service registry for given services. Client discovery; Cliend directly talks to the SR.
- Load balancing on client side
- Cache the service registry, if requests fail, query the SR again for updated addresses
Server discovery: API Gateway talks to the SR instead of the client. Finds the service addressess.