define

DNS, short for Domain Name System, means Domain Name System. It is an Internet service. It is a distributed database that maps Domain names and IP addresses to each other.

At first, we use THE IP address to visit the web page, but because the IP is long and not easy to remember, so later there is a DNS server, the domain name and IP address mapping, so that we can enter the domain name when visiting the website, the DNS server will resolve the domain name we enter into the IP address, to achieve the website access.

In layman’s terms, DNS is a super-distributed database that records IP addresses.

The characteristics of

  • High availability: Because everyone is likely to use domain name resolution on the Internet, the DNS server is especially important and can cause a lot of trouble if it fails.
  • Distributed: Because domain name resolution is used by people all over the world, the DNS server should be distributed

Design structure

DNS is designed as a tree-like structure in response to the two characteristics described above.

  • The top layer is the root domain server, which is used to query the top-level domain server
  • The second layer is the top-level domain server, which returns the authoritative domain name server
  • The third layer is the authoritative domain name server, which returns the specific IP address corresponding to the specific domain name
  • In addition, the network carrier deploys some cache domain name servers nearby. If there is an IP address in the cache, the DNS server returns the IP address directly

Let’s take a look at it server by server.

Root domain and root domain server

The root DNS server is used to query top-level domain servers. There are 13 groups of root DNS servers in the world.

When we enter www.google.com to visit a website, we are actually visiting a different domain, www.google.com represents a different domain, but there is another domain following.com, but because it is the default domain name system, we don’t need to write it here, this is the root domain.

In other words, the domain name should look like this:

The root domain www.google.com.

When we visit, it asks the root server for the address of the COM domain. Then the request continues down through the WIN domain. The root DNS server does not directly resolve the domain name to be queried to the IP address, but tells the local DNS server which TOP-LEVEL DNS server to search for next.

So the root DNS server is important. If all the root DNS servers go down, the entire DNS system won’t work.

Top-level domains and top-level domain servers

Again, take www.google.com, where com is the top-level domain. In addition to com, there are many other top-level domains, such as CN, NET, edu, etc.

The TOP-LEVEL domain name server manages the secondary domain names registered with the top-level domain name server and returns the corresponding authoritative domain name server.

Authoritative DNS and authoritative domain name server

The authoritative DNS server resolves the domain name and returns the IP address corresponding to the domain name.

Carrier DNS server and local DNS server

In the real Internet, we do not directly connect to the root server, but to the Internet through the local DNS server. The local DNS server generally refers to the domain name resolution server provided by local carriers. You can also build your own server.

The parsing process

Knowing the DNS servers, let’s take a look at the resolution process.

  1. When we visit a web site, the client makes a domain name resolution request and sends the request to the local domain name server
  2. After receiving the request, the local DNS server checks the cache in the local host file. If the record exists, the local DNS server directly returns the query result
  3. If the record does not exist in the local cache, a query request is sent to the local DNS server
  4. After receiving a request, the local DNS server checks whether the IP address of the requested website is in the local cache. If yes, the local DNS server returns the IP address directly
  5. If there is no query in the cache, the local DNS server sends a query request to the root DNS server
  6. After receiving the request, the root DNS server does not directly return the corresponding IP address. Instead, it looks at the top-level domain name and returns the top-level domain name server to the local DNS server
  7. The local DNS server sends a query request to the TOP-LEVEL domain name server. After receiving the request, the TOP-LEVEL domain name server does not directly return the corresponding IP address, but returns the authoritative DNS server
  8. The local DNS server sends a query request to the authoritative DNS server. The authoritative DNS server returns the IP address corresponding to the specific domain name
  9. The local DNS server returns the IP address to the client
  10. The client connects to the corresponding server using an IP address

During the whole access process, the client actually only sends a query request once, and the recursive query process is completed by the DNS server.

Load balancing and proximity access

For our application, in order to ensure its high availability, we will deploy its code and data in multiple rooms, each room has its own IP, and each room is hosted in different carriers and regions. For users, they want to access the data center in the equipment room nearby. This process is called nearby access.

The way to do this is to use a global load balancer. The global load balancer is abbreviated GSLB. Let’s take a look at the process:

  • Suppose you have an application that has multiple rooms in different locations hosted by different carriers. When we visit a website and go through a DNS query, we configure a CNAME alias instead of the corresponding IP address for the nearest access across regions and carriers.

  • With the CNAME alias, the local DNS server can request GSLB to resolve the domain name.

  • Once the GSLB receives the request, it can find out what the user’s carrier and address are by looking at the carrier and location of the local DNS requesting it. In this case, GLSB returns the IP address of the machine room nearest the user and the same carrier to the local DNS server.

  • The local DNS server returns the IP address to the client. After obtaining the IP address, the client can access the nearest equipment room.