Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microservice, amqp and service registry / discovery

I m studying Microservices architecture and I m actually wondering something.

I m quite okay with the fact of using (back) service discovery to make request able on REST based microservices. I need to know where's the service (or at least the front of the server cluster) to make requests. So it make sense to be able to discover an ip:port in that case.

But I was wondering what could be the aim of using service registry / discovery when dealing with AMQP (based only, without HTTP possible calls) ?

I mean, using AMQP is just like "I need that, and I expect somebody to answer me", I dont have to know who's the server that sent me back the response.

So what is the aim of using service registry / discovery with AMQP based microservice ?

Thanks for your help

like image 813
mfrachet Avatar asked Nov 27 '15 07:11

mfrachet


People also ask

What is service registry and service discovery in Microservices?

A service registry is a database used to keep track of the available instances of each microservice in an application. The service registry needs to be updated each time a new service comes online and whenever a service is taken offline or becomes unavailable.

Is service discovery mandatory in Microservices?

In a microservices application, the set of running service instances changes dynamically. Instances have dynamically assigned network locations. Consequently, in order for a client to make a request to a service it must use a service‑discovery mechanism.

How Microservices communicate with each other what is service discovery?

What is Service Discovery in Microservices? Microservices service discovery is a way for applications and microservices to locate each other on a network. Service discovery implementations within microservices architecture discovery includes both: a central server (or servers) that maintain a global view of addresses.

How many types of the registry is there in Microservices?

There are two options: Self registration pattern - service instances register themselves. 3rd party registration pattern - a 3rd party registers the service instances with the service registry.


1 Answers

AMQP (any MOM, actually) provides a way for processes to communicate without having to mind about actual IP addresses, communication security, routing, among other concerns. That does not necessarily means that any process can trust or even has any information about the processes it communicates with.

Message queues do solve half of the process: how to reach the remote service. But they do not solve the other half: which service is the right one for me. In other words, which service:

  • has the resources I need
  • can be trusted (is hosted on a reliable server, has a satisfactory service implementation, is located in a country where the local laws are compatible with your requirements, etc)
  • charges what you want to pay (although people rarely discuss cost when it comes to microservices)
  • will be there during the whole time window needed to process your service -- keep in mind that servers are becoming more and more volatile. Some servers are actually containers that can last for a couple minutes.

Those two problems are almost linearly independent. To solve the second kind of problems, you have resource brokers in Grid computing. There is also resource allocation in order to make sure that the last item above is correctly managed.

There are some alternative strategies such as multicasting the intention to use a service and waiting for replies with offers. You may have reverse auction in such a case, for instance.

In short, the rule of thumb is that if you do not have an a priori knowledge about which service you are going to use (hardcoded or in some configuration file), your agent will have to negotiate, which includes dynamic service discovery.

like image 180
Akira Avatar answered Sep 21 '22 14:09

Akira