Introduction to DNS
DNS, or Domain Name System, is the foundational directory of the internet. It translates human-readable domain names like google.com into machine-readable IP addresses. For a deeper understanding of how this fits into the broader web experience, see The Hidden Magic Behind Accessing Your Favorite Websites.
Components of DNS
DNS comprises various server types in a hierarchical structure:
- DNS Resolver: The initial point a browser queries, often provided by an ISP or services like Cloudflare (1.1.1.1) and Google DNS (8.8.8.8). It checks cached entries before querying deeper layers.
- Root Name Servers: Thirteen logical servers holding IP addresses of all Top-Level Domain (TLD) servers, distributed globally with anycast routing for efficiency.
- TLD Name Servers: Manage IP addresses of authoritative nameservers for all domains within a TLD, e.g.,
.com,.org, country codes like.uk. - Authoritative Name Servers: Hold definitive DNS records for specific domains, updated through domain registrars or cloud providers like AWS. To understand how these servers fit into backend systems, see Understanding Backend Architecture: How Requests Travel and Why Backends Matter.
The DNS Query Process
- User enters a domain (e.g., google.com) into a browser.
- Browser checks its cache; if not found, queries the operating system cache.
- The OS requests the DNS resolver.
- Resolver checks its cache; if missing or expired, asks the root name server.
- Root server provides the IP addresses of the relevant TLD servers (e.g.,
.com). - Resolver queries the TLD name server, which returns the authoritative nameservers for the domain.
- Resolver contacts the authoritative nameserver to get the domain’s IP address.
- IP address is returned back to the browser for connection.
To see how your data travels through the internet during this process, visit The Hidden Magic Behind Browsing: How Your Data Travels the Internet.
Managing DNS Updates in Production
DNS changes require careful propagation management due to TTL (Time To Live) settings:
- Issue: Long TTLs cause delays in update propagation; some resolvers ignore TTLs.
- Best Practices:
- Lower TTL to about 60 seconds well before changes to speed up propagation.
- Maintain the old server alongside the new one post-update until traffic stabilizes.
Summary
DNS's hierarchical and decentralized design ensures robustness and scalability of the internet by efficiently resolving domain names to IP addresses. Understanding DNS operations and update management is essential for maintaining reliable web services.
For deeper insights into system design, consider subscribing to the ByteByteGo newsletter, trusted by over 250,000 readers, covering large-scale system design trends.
DNS, or Domain Name System, is the backbone of
the internet, but few know exactly how it works. In this video, we will learn all
about the system design of DNS. Let’s dive right in.
DNS is the internet’s directory. It translates human-readable domain names, such
as google.com to machine-readable IP addresses. DNS is a little confusing because there
are different types of DNS servers in the
DNS hierarchy, each serving a different purpose. When a browser makes a DNS query,
it’s asking a DNS resolver. This DNS resolver could be from our ISP,
or from popular DNS providers like
Cloudflare’s 1.1.1.1, or Google’s 8.8.8.8. If the DNS resolver does not
have the answer in its cache, it finds the right authoritative
nameserver and asks it.
The authoritative nameserver is
the one that holds the answer. When we update a domain’s DNS records, we
are updating its authoritative nameserver. How does the DNS resolver find
the authoritative name server?
This is where the system of DNS gets interesting. There are three main levels
of authoritative DNS servers. They are the root name servers, the
top level domain (or TLD) name servers,
and the authoritative nameservers for the domains. The root name servers store the IP
addresses of the TLD name servers. There are 13 logical root name servers.
Each root name server has a
single IP address assigned to it. There are actually many physical
servers behind each IP address. Through the magic of anycast, we
get routed to the one closest to us.
The TLD name servers store the IP addresses of the authoritative name servers
for all the domains under them. There are many types of TLD names.
We are all familiar with .com, .org and .edu. There are also country code TLDs like .de and .uk. There are many others.
The authoritative name servers
for a domain provide, well, authoritative, answers to DNS queries. When we register a domain, the
registrar runs the authoritative
nameservers by default, but
we can change them to others. Cloud providers like AWS and Cloudflare
run robust authoritative nameservers. This hierarchical design makes DNS
highly decentralized and robust.
Let’s walk through the life
of a typical DNS query. The user types google.com into the browser. The browser first checks its cache.
If it has no answer, it makes an operating
system call to try to get the answer. The operating system call would
most likely have its own cache. If the answer isn’t there, it
reaches out to the DNS resolver.
The DNS resolver first checks its cache. If it’s not there or if the answer has
expired, it asks the root name server. The root name server responds with
the list of the .com TLD name servers.
Note that since .com is such a common TLD, the resolver most likely already caches the
IP addresses for those .com TLD nameservers. The DNS resolver then reaches
out to the .com TLD nameserver,
and the .com TLD nameserver returns the
authoritative nameservers to google.com. And finally, the DNS resolver reaches out
to google.com’s authoritative nameserver, and it returns the IP address of google.com
The DNS resolver then returns the
IP address to the operating system, the operating system returns it to the browser. Finally, let’s go over some gotchas
when updating DNS records for a live,
high-traffic production system. DNS propagation is slow because
there is a TTL on each DNS record. And some of the default TTLs are pretty long.
Also, not every DNS resolver is a good citizen.
There are some out there that don’t honor the TTL. To mitigate the risk, there are
two practical steps to take. First, reduce the TTL for the record that
we want to change to something very short,
say 60 seconds, well in advance
before the update actually happens. This gives ample time for all the DNS
servers to receive the shortened TTL which would allow the actual record update to
take effect based on the new shortened TTL.
Second, leave the server running
on the old IP address for a while. Only decommission the server when
traffic dies down to an acceptable level. Because some DNS resolvers don’t honor the TTL,
this could take a bit of time and patience.
This concludes our video on DNS. We hope you have a better understanding of how its hierarchical design makes
it decentralized and robust.
Remember, DNS is what translates
domain names to IP addresses, making it a critical component
of the internet backbone. If you like our videos, you may like
our system design newsletter as well.
It covers topics and trends
in large-scale system design. Trusted by 250,000 readers. Subscribe at blog.bytebytego.com
The DNS system consists of several key components: DNS Resolvers, which act as the first query point often provided by ISPs or services like Cloudflare and Google DNS; Root Name Servers, which provide IP addresses for Top-Level Domain (TLD) servers; TLD Name Servers that manage IP addresses of authoritative servers within each domain extension like .com or .org; and Authoritative Name Servers that hold the definitive DNS records for specific domains. Each component plays a critical role in efficiently translating domain names to IP addresses.
When you enter a domain name like google.com, your browser first checks its cache for the IP address. If not found, it queries the operating system, which then contacts the DNS resolver. The resolver checks its cache; if missing, it queries the root name server to get TLD server info, then the TLD server to obtain the authoritative nameservers, and finally the authoritative nameserver for the domain's IP address. This IP is returned to your browser to establish the connection.
DNS updates can propagate slowly due to high TTL (Time To Live) settings, causing cached information to remain outdated in resolvers. Some resolvers may even ignore TTL values. To manage this, it’s best to lower the TTL to around 60 seconds ahead of planned changes and maintain both old and new servers simultaneously until traffic stabilizes, ensuring seamless updates without service disruption.
Root Name Servers serve as the foundational layer in DNS, holding the IP addresses for all TLD servers like .com, .org, and country-specific domains. They help direct DNS resolvers to the correct TLD servers, enabling efficient domain resolution. There are thirteen logical root servers distributed globally using anycast routing to improve performance and reliability.
DNS resolvers improve lookup efficiency by caching DNS responses from previous queries, which reduces the need to repeatedly query higher DNS hierarchy levels. When a resolver receives a query, it first checks its cache for a valid IP address, quickly returning it if present, thereby speeding up the resolution process and reducing network traffic.
Web administrators should lower DNS TTL values to about 60 seconds well before making changes to ensure faster propagation. They should also keep the old server active alongside the new one after updates until traffic stabilizes. This approach minimizes downtime or service interruptions caused by DNS caching delays during transitions.
DNS’s hierarchical and decentralized design distributes the responsibility of resolving domain names across various servers globally, which ensures scalability to handle vast queries and robustness against failures. This structure prevents bottlenecks and single points of failure, maintaining reliable web service access worldwide even under heavy loads or isolated outages.
Heads up!
This summary and transcript were automatically generated using AI with the Free YouTube Transcript Summary Tool by LunaNotes.
Generate a summary for freeRelated Summaries
The Hidden Magic Behind Accessing Your Favorite Websites
Discover the complex technology and processes that power your internet experience.
The Hidden Magic Behind Browsing: How Your Data Travels the Internet
Discover the complex journey of data from click to display, revealing the tech behind seamless web browsing.
Understanding Backend Architecture: How Requests Travel and Why Backends Matter
This comprehensive summary explains the fundamental concepts of backend servers, tracing the journey of a web request from a browser to a server deployed on AWS, including DNS resolution, firewall filtering, reverse proxy configuration, and node server processing. It also contrasts backend and frontend roles, highlighting security, performance, and architectural reasons why backend logic cannot be fully executed in frontend environments.
Scalable System Design Explained Using a Restaurant Analogy
Explore how building a scalable, resilient system parallels running a growing pizza parlor. This guide covers vertical and horizontal scaling, fault tolerance, microservices, load balancing, and decoupling with real-world examples to simplify complex technical concepts.
Designing a Network for XYZ Company: A Step-by-Step Guide
In this video, we tackle the second networking project for XYZ Company, which involves designing a separate network for a new branch. We cover the requirements, including VLAN configuration, DHCP setup, and inter-VLAN routing, ensuring all departments can communicate effectively.
Most Viewed Summaries
Kolonyalismo at Imperyalismo: Ang Kasaysayan ng Pagsakop sa Pilipinas
Tuklasin ang kasaysayan ng kolonyalismo at imperyalismo sa Pilipinas sa pamamagitan ni Ferdinand Magellan.
A Comprehensive Guide to Using Stable Diffusion Forge UI
Explore the Stable Diffusion Forge UI, customizable settings, models, and more to enhance your image generation experience.
Mastering Inpainting with Stable Diffusion: Fix Mistakes and Enhance Your Images
Learn to fix mistakes and enhance images with Stable Diffusion's inpainting features effectively.
Pamamaraan at Patakarang Kolonyal ng mga Espanyol sa Pilipinas
Tuklasin ang mga pamamaraan at patakaran ng mga Espanyol sa Pilipinas, at ang epekto nito sa mga Pilipino.
Pamaraan at Patakarang Kolonyal ng mga Espanyol sa Pilipinas
Tuklasin ang mga pamamaraan at patakarang kolonyal ng mga Espanyol sa Pilipinas at ang mga epekto nito sa mga Pilipino.

