Best practices for detecting microservices without hard coding?

This is a question that annoys me for a while, how to write a number of microservices that work on different machines in different places without the need for hard coding of each service in a separate location?

Like for example, I had a service A that does some form of json message validation. Service A runs on box 1,3,5, and more cases can be raised as demand grows.

Now tell me that I have service B that wants to call service A, how can I contact service B, where is my service A?

Possible solutions that I reviewed:

  • Hard coding service B with a "master" node location for service A, which then delegates tasks for all instances of service A.

  • Using message queues? - Service B writes to the message queue queue, Service A instances read from the specified message queues, and sends the results to service B.

  • SSDP is the use of some form of a simple service discovery protocol to broadcast those services that are on the network and track these services.

I am new to this architectural style, so I hope I haven’t missed something very simple.

+4
source share
2 answers

Generally speaking, there are two approaches to implementing service discovery:

+2

. , ( ).

. . ! DNS. , https://registry-1 IP-, .

, , , . DNS , . . ( ), .

, , , .

+2

Source: https://habr.com/ru/post/1649711/


All Articles