Names Instead of Addresses
In a dynamic cloud, instances come and go, so hard coding IP addresses is fragile. DNS based service discovery lets clients look up a service by name and receive the current set of healthy addresses, so the lookup adapts as the backends change.
How It Works
A registry keeps track of which instances are healthy and updates DNS records.
- A service registers under a name such as orders dot internal.
- Health checks remove failing instances so their addresses stop being returned.
- Clients resolve the name and get back current addresses rather than stale ones.
Watch The Cache
DNS answers carry a time to live, and clients may cache them for that duration. A long time to live means clients keep using old addresses after a change, so service discovery records usually set a short time to live to react quickly to instance churn.
Key idea
DNS based service discovery maps a service name to its current healthy instances through a registry with health checks, and short time to live values keep clients from caching stale addresses.