What is Service Discovery?
Service discovery, told as a story about a sign that always shows which booths are open right now.
Booths open and close, and not knowing which is which means lining up at a closed one.The paper map says booth 2 is open — but it isn't anymore.
The count changes on its own, and a paper map goes stale fast.Two more just opened, and no one updates the paper in time.
Every time a booth opens or closes, it registers or erases itself on the sign.So everyone just has to check the latest sign.
Rides look at the sign too, to find each other.Not just guests — rides find one another through the sign as well.
If the sign still says "open" right after closing, it's a wasted trip.Pairing it with health checks is what keeps the sign accurate.
Service discovery = having each booth register and erase itself on the sign the instant it opens or closes, so everyone only ever needs to read the latest sign. A wrong sign means a wasted trip, so it's paired with health checks.
A mechanism where servers (service instances) register and deregister themselves as they scale up and down, in a registry other services or load balancers can always query for the current list. It's sometimes built on DNS, and becomes essential once paired with autoscaling.
When grown-ups say it
- Service discovery
- The whole system behind a sign that shows what's open right now. Essential wherever the number of booths keeps changing.
- Registry
- The actual sign where the booth list is written. Everyone only has to check this one place.
- Register / deregister
- What a booth does to itself when it opens or closes. No one writes it for you — it writes and erases itself.
- Health-check integration
- Confirming a booth is truly alive, and fixing the sign accordingly. Trusting registration alone can leave a stale sign behind.
- DNS-based discovery
- Finding things by a name tag, like the town directory. Same idea as the town directory. → the town directory
- Relation to autoscaling
- Its partnership with the thing that adds and removes booths automatically. Since the count changes automatically, the sign has to keep up automatically too.
- Load balancer
- The usher who decides which booth to send a guest to. It reads the sign to decide where to send each guest. → the queue usher
- Service mesh
- The system that manages the paths rides take between each other. Service discovery is one part of finding that path.