Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microservices. What is difference between Service registry and service discovery

I am new to Microservices. I came across terms Service registry and service discovery.

What I understood is when a new service (or service instance) comes up, then it will register itself with the "service registry". It is also mentioned that the client can contact a service registry and get the list of IP-ports where that service is available.

In that case, what is the role of "service discovery".

Edit

Accepted answer. Also, more theoretical details were found https://www.nginx.com/blog/service-discovery-in-a-microservices-architecture/

like image 941
Kaushik Lele Avatar asked Jun 14 '17 09:06

Kaushik Lele


2 Answers

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.

like image 97
Ashish Vyas Avatar answered Sep 18 '22 01:09

Ashish Vyas


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.

like image 45
SigmaX Avatar answered Sep 18 '22 01:09

SigmaX