The need for Service Discovery in the microservices architecture
As we know, in the microservices architecture, various protocols may be used for connecting services to each other. But how do these services find each other?
And also, one service may have multiple instances. So, what happens if we run multiple instances? Let's look at the following diagram:
As you can see, there are two services running in this microservices-based application—Account Service and Customer Service. Account Service requests Customer Service to fetch records of a customer in JSON format. And both services have their own DB access—Account DB and Customer DB, respectively. Also, Customer Service has multiple running instances due to high availability and throughput, and to make it resilient. But how will Account Service call Customer Service? Which instance should be called?
To answer these questions, Service Discovery comes into the picture and solves these cloud-native problems. Let's look at the diagram with Discovery...