System DesignEasy
What is service discovery and why do microservices need it?
Service discovery is the mechanism that lets one microservice find the current network endpoints of another by a stable logical name (e.g., payments-api) instead of a hard-coded IP or port.
Why microservices need it:
- Pod / container IPs are not stable. Every deploy, restart, autoscale, or node failure can change them.
- Hard-coded URLs break the first time something moves.
- You need a level of indirection: caller asks for a name → registry returns one or more live endpoints.
What it solves (four things at once):
- Naming — services find each other by stable name, not IP.
- Health — only healthy instances are returned.
- Load balancing — calls are distributed across instances.
- Failure handling — dead instances drop out of the registry within seconds.
Two patterns you''ll meet:
- Client-side (Netflix Eureka, Consul) — caller queries the registry and picks an instance itself.
- Server-side (Kubernetes Services, AWS ELB) — caller hits a stable LB; the LB does the lookup.
In 2026, the default for new microservices is server-side via Kubernetes Services + cluster DNS — no extra registry needed.