Back to Blog
Lesson 3 of the System Design: System Design Fundamentals course
ArchitectureJuly 14, 20264 min read

Understanding DNS and Domain Resolution for Scalable Systems

Master the DNS lookup process, configure core records, and troubleshoot resolution issues to ensure your infrastructure is reachable and reliable.

DNSnetworkinginfrastructureroutingsystem designweb development

Previously in this course, we defined our system requirements in defining-system-requirements-for-scalable-software-architecture and mapped out our high-level components in high-level-architecture-diagramming-for-scalable-systems. Now that we have our architectural blueprint, we need to ensure users can actually find our servers.

The Domain Name System (DNS) is the critical infrastructure layer that translates human-readable hostnames like api.myapp.com into machine-readable IP addresses. Without a solid understanding of how this resolution works, your system remains an unreachable island.

The DNS Lookup Process: From Query to IP

Think of DNS as a hierarchical, distributed database. When a client requests a domain, the system doesn't just guess; it follows a deterministic path.

  1. Recursive Resolver: Your ISP or a service like Google (8.8.8.8) receives your request. It checks its local cache first.
  2. Root Nameservers: If not cached, the resolver asks the Root server, which knows where the Top-Level Domain (TLD) servers (like .com or .org) live.
  3. TLD Nameservers: The TLD server points the resolver to the Authoritative Nameservers for your specific domain (e.g., ns1.registrar.com).
  4. Authoritative Nameserver: This server holds the actual "source of truth" records for your domain and returns the IP address.
Flow diagram: Client → 1. Query Resolver; Resolver → 2. Where is .com? Root; Root → 3. TLD server Resolver; Resolver → 4. Where is myapp.com? TLD; TLD → 5. Auth server Resolver; Resolver → 6. What is the IP? Auth; Auth → 7. 192.0.2.1 Resolver; Resolver → 8. Return IP Client

Configuring Basic DNS Records

In your project’s design document, you must specify how traffic enters your network. You’ll manage this via your domain registrar's control panel by creating specific record types:

  • A Record: Maps a hostname to an IPv4 address. This is the most common way to point a domain to a server.
  • CNAME Record: An alias. It points one name to another (e.g., www.myapp.com points to myapp.com). Never use CNAMEs for the root domain (the "apex").
  • MX Record: Directs email traffic.
  • TXT Record: Used for verification (like proving you own the domain for SSL certificates) or security policies like SPF/DKIM.

Example Configuration: If your load balancer (which we will build in the next lesson) has an IP of 203.0.113.42, your DNS setup would look like this:

TypeHostValue
A@203.0.113.42
CNAMEwwwmyapp.com

Troubleshooting Resolution Issues

When users report that your site is "down," the issue is often DNS, not your application code. Use these tools to diagnose:

  • dig (Domain Information Groper): The industry standard. Run dig myapp.com to see the response. Check the "status" field—NOERROR is good, NXDOMAIN means the record doesn't exist.
  • nslookup: A simpler, cross-platform alternative for quick checks.
  • TTL (Time-to-Live): If you update a record and don't see changes, it's likely DNS caching. TTL defines how long a resolver should hold that record before fetching it again. Lowering your TTL before a migration is a pro move.

Hands-on Exercise

  1. Open your terminal and run dig google.com +short. Note the IP address.
  2. Now, try dig google.com @8.8.8.8 to force the query through Google's public DNS.
  3. Identify the TTL value for a domain you own (or a public one like wikipedia.org) using dig wikipedia.org. Explain why that number might be set to 3600 seconds (1 hour).

Common Pitfalls

  • Apex CNAMEs: Don't put a CNAME on your root domain (e.g., myapp.com). Use an ALIAS or ANAME record if your DNS provider supports it, otherwise use an A record.
  • Propagation Delays: DNS changes aren't instant. If you change an IP, it can take anywhere from a few minutes to 48 hours for global caches to clear.
  • Dangling Records: Removing a server but leaving the DNS record pointing to it creates a security risk; always clean up your records. Learn more about subdomain-takeover-prevention-securing-dns-against-dangling-cnames to avoid this.

FAQ

Q: Why does my site load on some networks but not others? A: This is usually due to DNS propagation or local caching on the user's ISP.

Q: What is the difference between an A record and a CNAME? A: An A record points to a static IP address; a CNAME points to another hostname, which is useful when your infrastructure IP changes frequently (common in cloud environments).

Q: Should I use cloud-native DNS? A: Yes. Services like AWS Route53 or Cloudflare provide advanced features like health checks and latency-based routing that standard registrar DNS lacks.

Recap

DNS is the foundation of your system's reachability. By understanding the lookup hierarchy, correctly configuring A and CNAME records, and mastering dig for troubleshooting, you ensure that your infrastructure is accessible to the world. Proper DNS management is a prerequisite for the high availability we will discuss in later modules.

Up next: The Role of the Load Balancer

Similar Posts