← Lessons

quiz vs the machine

Gold1390

System Design

The Service Discovery

How services find each other when instances come and go.

4 min read · core · beat Gold to climb

The moving target problem

Service instances start, stop, and move across hosts as they scale or recover. Hardcoding addresses breaks the moment an instance changes. Service discovery lets a caller find a healthy instance at runtime.

The registry

A service registry holds the live address of every instance. Instances register on startup and send heartbeats; unhealthy ones are removed.

Two lookup styles

  • Client side discovery: the caller asks the registry and picks an instance itself.
  • Server side discovery: the caller hits a load balancer that queries the registry and forwards the request.

Why it matters

Discovery plus health checks means traffic only reaches live instances, enabling autoscaling and self healing without manual address updates.

Key idea

Service discovery uses a registry of live, health checked instances so callers always reach a working address as instances scale and move.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a service registry track?

2. How does client side discovery differ from server side?