Interview Preparation | Building Blocks - Domain Name System

December 16th, 2023

Introduction

This summary will serve to further cement my learnings taken when reviewing the Domain Name System module in the Grokking the Modern System Design Interview course, and I hope will provide some learnings to you as well.

Overview:

DNS is pivotal in networking. It acts as a distributed database, translating user-friendly domain names into IP addresses, facilitating seamless communication across the internet.

Just as a phone book streamlines contact retrieval, DNS acts as a centralized repository for translating domain names to IP addresses, crucial for efficient internet navigation.

Important Details about DNS

Name Servers:

Recognizing DNS as a distributed infrastructure is paramount. Name servers, the backbone of this structure, respond to user queries.

Resource Records (RR):

Our attention shifts to the granular level of DNS - resource records (RR). These smallest units of information store mappings of domain names to IP addresses. Types like A, NS, CNAME, and MX each play distinct roles.

Common Types of Resource Records:

| Type  | Description                                           | Name                   | Value                        | Example                                                  |
| ----- | ----------------------------------------------------- | ---------------------- | ---------------------------- | -------------------------------------------------------- |
| A     | Provides the hostname to IP address mapping           | Hostname               | IP address                   | (A, relay1.main.educative.io, 104.18.2.119)              |
| NS    | Provides the authoritative DNS for a domain name      | Domain name            | Hostname                     | (NS, educative.io, dns.educative.io)                     |
| CNAME | Provides the mapping from alias to canonical hostname | Hostname (Alias)       | Canonical name               | (CNAME, educative.io, server1.primary.educative.io)      |
| MX    | Provides the mapping of mail server                   | Hostname (Mail Server) | Canonical name (Mail Server) | (MX, mail.educative.io, mailserver1.backup.educative.io) |

Caching:

Caching’s strategic implementation across layers minimizes latency, ensuring swift responses to user queries while alleviating the overall load on the DNS infrastructure.

Hierarchy:

DNS’s hierarchical structure is a cornerstone of its scalability. The tree-like organization of name servers allows it to efficiently manage the ever-expanding database, a vital consideration for the robustness of the system.

DNS Hierarchy

The Domain Name System (DNS) is not a single server but a distributed infrastructure with servers at different hierarchies. This section introduces four types of servers in the DNS hierarchy: DNS resolver, Root-level name servers, Top-level domain (TLD) name servers, and Authoritative name servers.

DNS Resolver

  • Initiates querying sequence.
  • Forwards requests to other DNS name servers.
  • Can employ caching techniques.

Root-level Name Servers

  • Receive requests from local servers.
  • Maintain name servers for top-level domain names (e.g., .com, .edu).

TLD Name Servers

  • Hold IP addresses of authoritative name servers.
  • Provide a list of IP addresses for the queried domain.

Authoritative Name Servers

  • Organization’s DNS servers.
  • Provide IP addresses of web or application servers.

Iterative versus Recursive Query Resolution

DNS queries can be performed iteratively or recursively. Iterative queries involve local servers requesting root, TLD, and authoritative servers for the IP address. Recursive queries start with the end user requesting the local server, which then seeks information from root DNS name servers and other name servers.

Caching

Caching involves the temporary storage of frequently requested resource records, reducing response time and network traffic. Caching occurs at various levels, including the browser, operating systems, local name servers, and ISP’s DNS resolvers.

DNS as a Distributed System

Despite facilitating the distributed Internet, DNS itself is a distributed system. This section explores the advantages of the DNS’s distributed nature, including avoiding a single point of failure, achieving low query latency, and providing flexibility during maintenance.

Highly Scalable

DNS’s hierarchical structure enables scalability, with around 1,000 replicated instances of 13 root-level servers strategically placed worldwide.

Reliable

The reliability of DNS is ensured through caching, server replication, and the use of the User Datagram Protocol (UDP), which offers speed advantages.

Consistent

DNS sacrifices strong consistency for high performance. It provides eventual consistency, updating records lazily, and employs Time-to-Live (TTL) to manage cached record expiration.