
Get my system design playbook for FREE on newsletter signup:
This post outlines how DNS works. You will find references at the bottom of this page if you want to go deeper.
Share this post & I'll send you some rewards for the referrals.
Once upon a time, the internet was a quiet place with only a tiny number of sites.
Each server was assigned a unique number, called the Internet Protocol (IP) address.
It lets users reach the server via efficient routing over the network.
Yet it became difficult for users to remember each site’s IP address.
So they created a text file to map site names to IP addresses.
Although it temporarily solved their naming problem, it became extremely difficult to scale because the number of sites exploded.
So they set up a hierarchical distributed database called the Domain Name System (DNS).
Onward.
What Is a DNS Server and How Does It Work
Think of DNS as a phone book; it returns the IP address on a site name lookup.
Let’s dive in!
The browser checks its cache for the IP address when the user enters a site name.
The browser then queries the operating system’s cache to check if it has the site's IP address.
If not, the browser sends a request to the resolver server to find the IP address.
Think of the resolver server as a component to find the correct DNS server for a site name.
The Internet Service Provider (ISP) maintains the resolver server, and it checks its cache for the IP address.
The resolver server then sends a query to the closest root server. There are 13 root servers across the world.
Yet a root server doesn’t store the IP address.
Instead, it forwards the query to the correct top-level domain (TLD) server, such as .com or .org.
Imagine the root server as a DNS component to find the right TLD server.
But TLD doesn’t store IP addresses either.
Instead, it routes the query to the correct authoritative name server.
The authoritative name server contains the IP address; it responds to the resolver server.
The resolver then returns the IP address to the browser. While the browser queries the site’s web server directly to access it.
TL;DR:
DNS-DNS queries use Transmission Control Protocol (TCP) for reliability and security. While client-DNS queries use User Datagram Protocol (UDP) for low overhead and fast response. 1
The resolver server stores the IP address in its cache with an expiry time. This allows the server to handle future requests from different users quickly.
While the user’s operating system and browser cache DNS values, it helps to reduce bandwidth usage and latency.
Subscribe to get simplified case studies delivered straight to your inbox:
Want to advertise in this newsletter? 📰
If your company wants to reach a 100K+ tech audience, advertise with me.
Thank you for supporting this newsletter. Consider sharing this post with your friends and get rewards. Y’all are the best.
TL;DR 🕰️
You can find a summary of this article on Twitter. Please consider a retweet if you find it helpful.
Great post, Neo. The visuals are highly helpful in understanding how this protocol works.
Just a minor detail I read at the end. DNS not only uses TPC. DNS primarily uses UDP (User Datagram Protocol) for most queries and responses due to its speed and low overhead. However, it also utilizes TCP for specific tasks like zone transfers, which require reliable and large data transfers.
Thank you very much for this concise article!
It’s important to remember that there can be numerous other caches between the Operating System Cache and the Resolver System Cache. For example, there’s an Internet Provider Cache. Google collaborates with providers and strategically places their cache near users to ensure instantaneous service loading.