What is DNS? Introduction to Domain Name System – System Design 06

system-design-system design 06-system design components-what-is-dns-hogantech-hoganblab

Origin of DNS

First, let's use a mobile phone as an example, where each contact has a unique mobile phone number. If we need to call a friend today, we can simply enter the phone number and make the call. However, as the number of contacts increases, it is impossible for us to remember all the phone numbers, so we will store the address book in the mobile phone. When we need to make a call, we only need to find the corresponding contact information. You can make a call.

Well, in the information field, computers use IP addresses as contact numbers, for example: 140.112.0.0 It's just an IP address. We can use IP addresses to access websites hosted on our computers. However, as in the previous example, it is inconvenient for humans to identify so many IP addresses composed of numbers, so we have domain names. For example:google.com It is a Google website, and its corresponding IP is 142.250.191.78. We also need a place similar to an address book to record IP addresses and domain names.

What is DNS?

Domain Name System (DNS) is an Internet naming service (Domain Name System). This DNS system maps human-readable domain names to machine-readable IP addresses, such as:google.com The corresponding IP is 142.250.191.78. When a user enters a domain name into the browser, the browser must convert the domain name into an IP address through DNS. Once the required IP address is obtained, the user's request is forwarded to the target server.

DNS terms you need to know

Name Server

In fact, DNS is not a single server, but a Block composed of a large number of servers. The DNS server that responds to user queries is called a name server.

Resource Record

The DNS database stores the mapping of domain names to IP addresses in the form of resource records. RR is the smallest unit of information requested by a user from a name server, and there are different types of resource records. The following different resource records are provided here to provide readers with reference.

system-design-06-table

cache(Caching)

DNS uses different layers of caching to reduce user request latency. Caching plays an important role in alleviating the burden on the DNS as it must satisfy queries from the entire global Internet.

Hierarchy

DNS name servers are structured in a hierarchy. The hierarchical structure makes DNS highly scalable as its size and query load continue to increase.

How does DNS work?

AWS Diagram and Description

provided first AWS Illustrations and original text descriptions will be explained next with some proper nouns.

system-design-06-what-is-dns
  1. The user opens a web browser and enters in the address bar www.example.com, and then press Enter.
  2. right www.example.com Requests are routed to a DNS resolver, which is typically managed by the user's Internet Service Provider (ISP), such as a cable Internet provider, DSL broadband provider, or corporate network.
  3. The ISP's DNS resolver will www.example.com Requests are forwarded to the DNS root name servers.
  4. ISP's DNS resolver forwards again www.example.com The request is forwarded this time to one of the TLD name servers for the .com domain. The name servers for the .com domain use the same example.com The names of the four Amazon Route 53 name servers associated with the domain respond to requests.
  5. The ISP's DNS resolver selects the Amazon Route 53 name servers and www.example.com Requests are forwarded to this name server.
  6. Amazon Route 53 name servers are at example.com Search in hosting area www.example.com record, obtain the associated value (for example, the IP address of the web server 192.0.2.44), and pass the IP address back to the DNS resolver.
  7. The ISP's DNS resolver finally obtains the IP address required by the user. The parser passes this value back to the web browser. DNS resolvers will also example.com The IP address is cached (stored) for a period of time that you specify for the next time someone views it example.com It can respond faster. For more information, see Time to Live (TTL).
  8. The web browser sends a request to the IP address obtained from the DNS resolver. www.example.com request. For example, your content could be a web server running on an Amazon EC2 instance or an Amazon S3 bucket configured as a website endpoint.
  9. A web server or other resource located at 192.0.2.44 will www.example.com The web page is passed back to the Web browser, and the Web browser displays the page.

DNS Hierarchy

As described earlier, DNS is not a single server that accepts requests and responds to user queries, but is composed of many servers combined into a large system with different hierarchies of name servers.

DNS Hierarchy four types of servers

DNS resolver (Resolver)

The parser is used to turn the query string into a query sequence and forward the request to other DNS name servers. Normally, the DNS resolver itself exists on the user's network.

Root-level name servers (Root-level Name Server)

These servers receive requests from local servers. Root name servers maintain name servers based on top-level domains,For example.com, .edu, .us, etc. For example, when a user requests educational.io , the root name server will return a list of top-level domain (TLD) servers that hold the IP address for the .io domain.

Top-level Domain Server

These servers store the IP addresses of authoritative name servers. Querying parties will be provided with a list of IP addresses belonging to the organization's authoritative servers.

Authoritative name server (Authoritative Name Server)

These are the DNS name servers of some large companies that provide the IP addresses of web or application servers.

Iterative and recursive queries

There are two methods to perform DNS queries. CloudFlare's simplified DNS flow chart is also attached here. If you look closely, you can find that it is very similar to the AWS chart.

Iterative query

The local server requests an IP address from the root server, top-level domain name server (TLD), and authoritative name server (Authoritative Name Server).

recursive query

End user requests local server. The local server further requests the root-level name server. Root-level name servers forward requests to other name servers.

system-design-06-how-dns-work

cache

What is cache? Caching refers to storing frequently requested data in a certain place so that it can be quickly retrieved when needed.

In DNS, there will also be cache! Caching can significantly reduce user response times and reduce network traffic. When we use caching in different hierarchies, it can also reduce the burden of large queries on the DNS infrastructure. The cache can also be seen in the browser, operating system, local name servers within the user's network, or the ISP's DNS resolver.

DNS for decentralized systems

The previous article introduced the concept of distributed systems and also introduced the characteristics of a good software system. So let's talk about the parts of DNS related to abstractions, features, and requirements.

In fact, DNS itself is a decentralized system, and these decentralized features have the following advantages:

  1. It avoids becoming a single point of failure (SPOF).
  2. It achieves low query latency so users can get responses from nearby servers.
  3. It achieves a higher degree of flexibility during maintenance and updates or upgrades. For example, if one DNS server fails or is overloaded, another DNS server can respond to user queries.

Here we also explain how DNS improves scalability (Scalability), reliability (Reliability) and consistency (Consistency).

Scalability

DNS is a highly scalable system. according to Cloudflare According to the article, there are currently 13 root-level name servers in the world, and additional instances copied from these root servers are distributed around the world to handle user queries. These requests are distributed to the TLD and root servers to handle the query, and finally to the authoritative servers managed by the large companies themselves to keep the entire system functioning properly.

Reliability

cache

Caching is done in the browser, operating system, and local name servers, and ISP DNS resolvers also maintain rich caches of frequently accessed services. Even if some DNS servers are temporarily down, cache records can be provided, making DNS a reliable system.

Server replication

DNS systematically replicates each replica server around the world to reduce latency in processing user requests and improve the reliability of the entire system.

Consistency

DNS uses various protocols to update and transfer information between replicated servers in a hierarchy. DNS compromises on consistency to achieve high performance. Because data is read from the DNS database more frequently than written. However, DNS provides eventual consistency and delays updating records on replicated servers.

Consistency is also affected due to the caching mechanism mentioned earlier. Because the authoritative server is located within the organization, some resource records on the authoritative server may be updated in the event of a server failure in the organization. As a result, cache records on default/local and ISP servers may become stale. To mitigate this problem, each cache record has an expiration time called a time-to-live (TTL).

Postscript

This article is far from the previous one Introduction to System Design Components Building Block – System Design 05 It took a while, mainly because I spent more time understanding the principles of DNS, and I also believed that DNS is an essential knowledge that needs to be known whether in interviews or daily work, so I spent a lot of space and explained it in depth. DNS.

If it is a larger topic in the future, I will still spend a lot of space explaining it. Thank you for reading!

Quote

DNS Design: Scalability, Performance, Robustness

Cloudflare: What is a DNS root server?

AWS: What is DNS?

IBM: What is the DNS protocol?

related articles

Introduction to System Design Components Building Block – System Design 05

Back-of-the-envelope Back-of-the-envelope Calculation – System Design 04

Non-functional features of software design – System Design 03

Application of abstraction in system design – System Design 02

Introduction to Modern System Design - System Design 01

Leave a Comment

Your email address will not be published. Required fields are marked *

en_USEnglish