0
0
HLDsystem_design~7 mins

DNS and how domain resolution works in HLD - System Design Guide

Choose your learning style9 modes available
Problem Statement
When you type a website name like example.com, your device cannot connect directly because it needs the website's numeric address (IP). Without a system to translate names to IPs, users would have to remember complex numbers for every site, making the internet hard to use.
Solution
The Domain Name System (DNS) translates human-friendly domain names into IP addresses. When you enter a domain, your device asks DNS servers step-by-step, starting from root servers down to authoritative servers, to find the correct IP address. This process allows your device to connect to the right server using the IP.
Architecture
User Device
Recursive
Resolver
Root DNS
Server
TLD DNS
Server (.com)
Authoritative
DNS Server
Recursive
Resolver
User Device

This diagram shows the step-by-step query flow from the user's device to DNS servers: recursive resolver, root server, TLD server, and authoritative server, ending with the IP address returned to the user.

Trade-offs
✓ Pros
Allows users to use easy-to-remember domain names instead of IP addresses.
Hierarchical design distributes load and improves fault tolerance.
Caching at various levels reduces lookup time and network traffic.
✗ Cons
DNS queries can introduce latency due to multiple lookups.
If DNS servers are misconfigured or attacked, domain resolution can fail.
Caching can cause stale data if records change but caches are not updated promptly.
Always use DNS for any system requiring human-friendly domain names to IP resolution, especially for internet-facing services with millions of users.
For internal systems with fixed IPs and no need for human-friendly names, DNS may add unnecessary complexity.
Real World Examples
Google
Google Public DNS improves domain resolution speed and security for millions of users worldwide.
Netflix
Netflix uses DNS-based routing to direct users to the nearest content delivery network edge server for faster streaming.
Amazon
Amazon Route 53 provides scalable DNS services that route user requests to AWS resources reliably.
Alternatives
Hosts File
Local static file mapping domain names to IPs without network queries.
Use when: For small, isolated environments or testing where DNS infrastructure is unavailable.
mDNS (Multicast DNS)
Resolves names within local networks using multicast instead of hierarchical servers.
Use when: For zero-configuration networking in small local networks without central DNS.
Summary
DNS translates human-friendly domain names into IP addresses needed for network communication.
It uses a hierarchical query process involving root, TLD, and authoritative servers to find the correct IP.
Caching and distributed design make DNS scalable and fault-tolerant but can introduce latency and stale data.