0
0
Microservicessystem_design~3 mins

Why Service discovery concept in Microservices? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if your services could find each other instantly, no matter where they move?

The Scenario

Imagine you have many friends in a big city, and you want to call them. But you don't have their phone numbers saved anywhere. You have to ask around every time to find their current number before calling.

The Problem

This manual way is slow and frustrating. Friends change numbers often, and asking around wastes time. Sometimes you get wrong numbers or no answer, making communication unreliable and error-prone.

The Solution

Service discovery acts like a smart phonebook that always knows the latest numbers of your friends. It automatically keeps track of where each service lives and how to reach it, so you can connect instantly without searching.

Before vs After
Before
callService('user-service', 'ask around for address', request)
After
callService('user-service', serviceDiscovery.getAddress('user-service'), request)
What It Enables

It enables seamless, automatic connection between services that can move or change, making your system flexible and reliable.

Real Life Example

In a food delivery app, the order service needs to find the current location of the payment service to process payments. Service discovery helps the order service find the payment service instantly, even if it moves to a new server.

Key Takeaways

Manual tracking of service locations is slow and error-prone.

Service discovery automates finding and connecting services.

This makes microservices communication reliable and scalable.