Finding services dynamically
In a dynamic fleet, instances start, stop, and move constantly. Hardcoding addresses breaks immediately. A service registry is a directory where each instance registers itself and callers look up healthy instances by name.
Register and discover
- On startup, an instance registers its address and a service name.
- It sends heartbeats so the registry knows it is alive.
- A caller queries by name and gets a list of healthy addresses to call.
Keeping it fresh
If an instance crashes and stops heartbeating, the registry deregisters it after a timeout so callers stop routing to a dead address. This self healing is what makes discovery reliable.
Key idea
A service registry is a live directory of healthy instances, kept fresh by heartbeats, so callers always discover reachable addresses by name.