Foundations · L1DNS and service discovery

DNS and service discovery

Every request starts with a name. Learn how DNS turns it into an address, why changes take time to spread, and how services find each other inside your system.

L1 Must-knowFoundations19 min read
Fact-checked by AI against cited sources · Human review pendingLast reviewed 22 Oct 2026 · How we check content
Section 1 of 8

What broke

Late on 19 October 2025, AWS services in its Northern Virginia region, us-east-1, started to fail. The cause was one DNS name: dynamodb.us-east-1.amazonaws.com, the public address of DynamoDB in that region. 1

DynamoDB keeps hundreds of thousands of DNS records for its load balancers. Automation keeps them up to date. One part, the DNS Planner, writes new plans. Three copies of another part, the DNS Enactor, apply the plans in Route 53, AWS's DNS service. 1

That night, one Enactor hit unusually long delays. Another Enactor applied a newer plan, then started to delete old plans. At that moment, the slow Enactor wrote its much older plan over the new one. It had checked that its plan was newer, but only at the start, and that check was now out of date. The cleanup then deleted the old plan, which was now live. All IP addresses for the endpoint disappeared. 1

From 11:48 PM PDT, every system that used the public endpoint got DNS failures. That included AWS's own services. The servers behind the name were fine. Nobody could find them. 1

Engineers found the cause at 12:38 AM and restored the DNS records at 2:25 AM. Even then, clients came back only as their cached DNS records expired, between 2:25 and 2:40 AM. Other services, like EC2 launches, took many more hours. 1

Section 2 of 8

The idea in simple words

Computers talk to IP addresses, like 192.0.2.44. People and code use names, like www.example.com. DNS connects the two. 7

DNS is not one server. It is a tree of names, spread over many name servers. Each name server is responsible for its own part of the tree, called a zone. Resolvers walk the tree for you and cache what they learn. 2

Inside your own system, services have the same problem. Servers start, stop and move, so their addresses change. Service discovery is how one service finds the current addresses of another.

The key idea. DNS is a cache spread over the whole internet. Every answer has a TTL, and a change reaches users only after the old answers expire. Plan every DNS change, and every failover, around that delay.

Section 3 of 8

How it works

A lookup, step by step

Your app does not walk the tree itself. It asks a recursive resolver, often run by your internet provider or your company network. 7 The resolver does the work and answers your app. RFC 1034 calls this a recursive query. The resolver itself asks each name server iteratively: each server either answers or points to a server closer to the answer. 2

At the top of the tree are the root name servers. IANA lists 13 named root server authorities, run by 12 operators. 6 Below them are the servers for top-level domains like .com. Below those is the authoritative name server for your zone, which holds your records. 7

Step through a lookup from a cold cache.

A DNS lookup for api.example.com from a cold cache Your app Resolver Name servers api.example.com?type Acache empty ask roottry .com ask .comtry ns1ns1.example.com ask ns1203.0.113.10TTL 300 s kept 300 s203.0.113.10 one minute laterapi.example.com?from cache✓ no servers asked SeniorPath
  1. Your app asks the recursive resolver for the A record of api.example.com. The resolver has just started, so its cache is empty.
  2. The resolver asks a root name server. The root does not know the answer. It sends back the names of the name servers for .com.
  3. The resolver asks a .com server. It also does not know the answer. It sends back the name servers for example.com, such as ns1.example.com.
  4. The resolver asks ns1.example.com, the authoritative name server. It has the record: 203.0.113.10, with a TTL of 300 seconds.
  5. The resolver keeps the answer in its cache for up to 300 seconds. It also keeps the referrals. Then it returns the address to your app.
  6. A minute later, someone asks again. The resolver answers from its cache. If you change the record now, this resolver can keep the old answer for four more minutes.
Step 1 of 6

The second lookup is fast because of caching. In the Route 53 guide's example, the resolver keeps the .com referral to a domain's name servers, typically for two days. 7

Record types you will meet

  • A: an IPv4 address, 32 bits. 3
  • AAAA: an IPv6 address. 8
  • CNAME: an alias. It says "this name is another name for that name". If a name has a CNAME, it should have no other records. 2 3
  • MX: the mail servers for a domain. 3
  • TXT: free text. 3
  • NS: the authoritative name servers for a zone. 3
  • SRV: where a service runs: a host name and a port, with a priority and a weight. Clients must try the lowest priority number first. Among equal priorities, a bigger weight gets more traffic. 5

TTL: why changes take time

Every record has a TTL in seconds. It is the time limit for keeping the record in a cache. 2 A TTL of zero means "use it for this lookup only, do not cache it". 3

The TTL is a trade-off. The Route 53 guide explains it. A long TTL, such as two days, means fewer queries, lower latency and a smaller bill. But a change, like a new IP address, takes longer to reach users. 8

So, before you change a record that is in use, lower its TTL first, for example to 300 seconds. Raise it again after you confirm the change works. 8 Our advice: lower it at least one old TTL before the change. Caches that read the record yesterday may still hold the long TTL.

Negative caching: "does not exist" is cached too

Resolvers also cache negative answers. NXDOMAIN means the name does not exist. NODATA means the name exists, but has no record of the type you asked for. 4 The time limit for a negative answer is the smaller of two values in the zone's SOA record. 4 RFC 2308 also says resolvers should cap it, and that a cap of one to three hours works well. 4

This causes a classic bug. A deploy script looks up a new name before the record exists. The resolver now remembers "no such name". You create the record, and lookups still fail until that negative answer expires.

DNS load balancing and failover

A DNS name can return several addresses. Route 53 can attach a health check to each record and answer only with healthy ones. 9 Two details matter. Route 53 runs health checks on a schedule, not when a query arrives. And a record without a health check is always treated as healthy. 9

DNS failover has a hard limit: the TTL. A new answer helps only clients that ask again. Everyone else keeps the cached address until its TTL ends. 2 AWS saw this in the outage above: clients reconnected only as their cached records expired. 1

DNS also knows nothing about load. It cannot see that one server is busy and another is idle. For that, put a load balancer behind the name. See load balancing.

Service discovery inside your system

Kubernetes explains the problem well. Pods come and go, and each Pod has its own IP address. A client should not need to track which Pods exist right now. 10

There are three common answers.

Plain DNS. Put internal names in DNS, with short TTLs. It is simple, and every language can use it. You still get the TTL delay, and DNS alone does not check health.

A service registry. Each instance registers itself in a registry like Consul. Health checks keep the list current. In Consul's DNS interface, you ask for <service>.service.consul. Instances that fail their health check are left out of the answer. SRV answers also return the port. 12

Kubernetes Services. A Service gets a DNS name like my-svc.my-namespace.svc.cluster.local. For a normal Service, it resolves to one cluster IP, which does not change when Pods change. 11 Kubernetes updates the Service's list of Pods whenever the set of Pods changes. 10 A headless Service has no cluster IP. Its name returns the IP of every Pod, and the client must choose. 11

A registry is a dependency of everything. In October 2021, Roblox was down for 73 hours. Roblox services used Consul to find each other, and when Consul was unhealthy, servers struggled to connect. Their telemetry also depended on Consul, so they lacked the data to see what was wrong. 13

Section 4 of 8

Trade-offs

OptionSpeed of changeHealth aware?Main risk
Public DNS, long TTLSlow. Old answers can live for the whole TTL. 8No A bad record stays in caches for a long time.
Public DNS, short TTLFast.No , unless you add health checks.More queries and a higher DNS bill. 8
DNS with health checks (Route 53)Limited by the TTL.Yes 9Records without a health check always count as healthy. 9
Service registry (Consul)Fast, if clients do not cache for long.Yes 12Every service depends on it. 13
Kubernetes Service (cluster IP)Fast. The IP stays the same. 11Partly. Kubernetes keeps the Pod list current. 10Only works inside the cluster.
Headless ServiceFast.Partly, like a normal Service.The client must pick a Pod and handle changes. 11

Simple rule: put a load balancer or a Kubernetes Service behind a stable name, and let DNS change rarely. Use DNS for "where is the front door", not for "which server is free right now".

Section 5 of 8

At work: how a senior uses this

  • Before a migration, write down the current TTL of every record you will change. Lower each TTL at least one old TTL before the move.
  • Never look up a name before you create it. Create the record first, then test it, so no negative answer gets cached.
  • Treat DNS automation like code that can break everything. Ask: "What stops this tool from writing an empty or stale record?" The AWS outage came from exactly that gap. 1
  • Keep the tools you use in an outage independent of the systems they watch. Roblox later removed the circular dependency between its telemetry and Consul. 13
  • Add a health check to every record in a failover group. A record without one counts as healthy. 9
  • When a service "cannot connect", check name resolution first: run dig against your resolver, and read the TTL in the answer.
Section 6 of 8

With AI

What to ask the agent

"Here is our DNS zone file. List every record with its TTL. For a move of api.example.com to a new load balancer, write a step-by-step plan with the time each step must wait."

"Search this repo for places where a service address is hard-coded, or where DNS answers are cached forever. Show the file and line, and how to make each one respect the TTL."

What to check yourself

  • Every TTL and wait time in the plan matches the real zone, not a guess. Run dig and compare.
  • The plan does not depend on deleting and re-creating a record. That can cause negative caching.
  • Any claim about caching in your language or HTTP client is backed by its official documentation.
  • For Kubernetes, the agent used the right namespace. A short name only finds Services in the Pod's own namespace. 11
Section 7 of 8

Check yourself

1. You will move api.example.com to a new IP address next week. Its TTL is 86400 seconds (one day). What should you do first?

Show answer

Lower the TTL, for example to 300 seconds, at least a day before the move. Raise it again after the move works. Resolvers may keep the old answer for the old TTL. Lower it early, so old answers expire fast on the day. Deleting the record can cause cached "does not exist" answers.

2. A health check marks one of your two servers as down. Route 53 stops returning its address. Why do some users still reach the dead server for a few minutes?

Show answer

Resolvers and clients cached the old answer, and they keep it until its TTL ends. A DNS change helps only clients that ask again. Cached answers live until their TTL ends, so failover is never faster than the TTL.

3. Your app looked up new-api.example.com before you created the record. You create it now. Why might lookups still fail for a while?

Show answer

The resolver cached the "name does not exist" answer. This is negative caching. Resolvers cache negative answers too. RFC 2308 takes the time limit from the zone's SOA record.

4. In Kubernetes, what does the DNS name of a normal (not headless) Service resolve to?

Show answer

The Service's cluster IP, which stays the same while Pods change. A normal Service gets one stable cluster IP. A headless Service, without a cluster IP, returns the IPs of the Pods instead.

Your progress is saved only in this browser. Export it to keep it safe.

Was this clear?
Report a mistake (opens GitHub in a new tab)
Section 8 of 8

Go deeper

Show 13 sources and related lessons
  1. Amazon Web Services, “Summary of the Amazon DynamoDB Service Disruption in the Northern Virginia (US-EAST-1) Region” (October 2025) (opens in a new tab)
    The postmortem. A race between two copies of the DNS automation left the DynamoDB endpoint with no IP addresses.
  2. P. Mockapetris, RFC 1034, “Domain Names - Concepts and Facilities”, IETF, 1987 (opens in a new tab)
    The parts of DNS (name space, name servers, resolvers), zones, recursive and iterative queries, the meaning of TTL, and the CNAME rule.
  3. P. Mockapetris, RFC 1035, “Domain Names - Implementation and Specification”, IETF, 1987 (opens in a new tab)
    Section 3.2 lists the record types (A, NS, CNAME, MX, TXT) and defines the TTL field.
  4. M. Andrews, RFC 2308, “Negative Caching of DNS Queries (DNS NCACHE)”, IETF, 1998 (opens in a new tab)
    How resolvers cache “this name does not exist”, and for how long.
  5. A. Gulbrandsen, P. Vixie, L. Esibov, RFC 2782, “A DNS RR for specifying the location of services (DNS SRV)”, IETF, 2000 (opens in a new tab)
    The SRV record format, with priority, weight, port and target.
  6. IANA, “Root Servers” (opens in a new tab)
    The 13 named root server authorities and who runs them.
  7. Amazon Route 53 Developer Guide: How internet traffic is routed to your website or web application (opens in a new tab)
    A lookup step by step, from the browser to the resolver, root, .com and the authoritative name servers.
  8. Amazon Route 53 Developer Guide: Values specific for simple records (opens in a new tab)
    Record types Route 53 supports, and the trade-off between a long and a short TTL.
  9. Amazon Route 53 Developer Guide: How health checks work in simple Amazon Route 53 configurations (opens in a new tab)
    DNS answers that include only healthy resources, and what happens to records without a health check.
  10. Kubernetes documentation: Service (opens in a new tab)
    Why Services exist. Pods come and go, and a Service gives clients one stable way to reach them.
  11. Kubernetes documentation: DNS for Services and Pods (opens in a new tab)
    The DNS names and records that Kubernetes creates for normal and headless Services.
  12. HashiCorp Consul documentation: Perform static DNS queries (opens in a new tab)
    The Consul DNS name format for services. Instances that fail their health check are left out.
  13. Roblox, “Roblox Return to Service 10/28-10/31 2021” (January 2022) (opens in a new tab)
    The postmortem of a 73-hour outage. Services found each other through Consul, and Consul was unhealthy.

Real incident: Amazon Web Services, 20 Oct 2025: AWS DynamoDB outage: an empty DNS record in us-east-1

Real incident: Roblox, 28 Oct 2021: Roblox outage: 73 hours down after Consul broke

Related: TCP/IP and the network stack · Load balancing · CDNs and HTTP caching · Safe deploys and config changes

Before this: TCP/IP and the network stack. Next: load balancing, which sits behind most DNS names, and CDN and HTTP caching, another cache with time limits.

Term

See full entry

Jump to a section

  1. 1What broke
  2. 2The idea in simple words
  3. 3How it works
  4. 4Trade-offs
  5. 5At work
  6. 6With AI
  7. 7Check yourself
  8. 8Go deeper