← Lessons

quiz vs the machine

Gold1450

Networking

The DNS Based Service Discovery

Finding healthy backends through names instead of fixed IPs.

5 min read · core · beat Gold to climb

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.

Check yourself

Answer to earn rating on the learn ladder.

1. What does DNS based service discovery return to a client?

2. Why do service discovery records use a short time to live?

3. What removes a failing instance from the returned addresses?