Talking about DNS Analysis

Introduction to DNS

IP is the address book in the computer, but IP is composed of a series of numbers, which is difficult for our brains to remember, so we need to define an address that conforms to the rules of human memory, and this is the domain name of the website we commonly use now. The domain name is our As a bridge to communicate with the computer, although we enter a string of English letters with human semantics in the browser, the computer will eventually resolve it into an IP address that can be recognized by itself, and this process is domain name resolution. The DNS service is responsible for resolving domain names into IPs.

Of course, the function of domain name resolution is not only convenient for memory, but also isolates the inconvenience caused by IP changes from the perspective of program design, and avoids IP changes caused by factors such as system migration and network replacement. On the other hand, from the perspective of system architecture, multiple system IPs can be configured on the domain name, and requests from multiple clients can be resolved to different IP addresses, so as to achieve the purpose of system distribution.

The first step we need to do when we use a domain name to access a website is domain name resolution. It is obviously unrealistic if domain name resolution requests from all over the world are requested to the same server, because DNS resolution is not only a large number of requests, but also if domain name resolutions from all over the world Both IP and IP relationship data exist in one place, and the amount of this data is also huge. Therefore, the design of DNS resolution must consider its own performance and usability issues.

The design of DNS resolution service fully embodies the idea of ​​diversion. The first is to split the domain name data vertically. The DNS resolution server is divided into root domain name server, top-level domain name server, and authoritative domain name server. Each layer is only responsible for the analysis of its own part of the domain name data. Split the domain name data, so as to avoid saving all domain name data by one server.

Then, the DNS servers at the horizontal layer are all clustered, and there are thousands of domain name servers distributed in the network for the root domain name server, which not only distributes the traffic, but also avoids the failure of domain names to provide services due to problems in parsing a certain DNS server.

DNS hierarchical design

The entire domain name resolution process is like the hierarchical division of labor in the company. The general manager knows which managers are responsible for which part, and the manager only knows which employees in his department are responsible for each part. The root domain name server is the general manager, which only knows all the top-level domain names (manager ) server address, while the top-level domain name only knows the address of the authoritative domain name server (employee) corresponding to the domain name. We all know in the company that employees are ultimately responsible for doing things, so every domain name resolution request will eventually fall to the authoritative server superior.

Layered domain name resolution process

Step 1: The domain name request will first request the root domain name server, and the root domain name server will return the corresponding top-level domain name server address according to the suffix of the domain name (.com, .org, .cn).

Step 2: After getting the address of the top-level domain name server, send a domain name resolution request to the address, and the top-level domain name server returns the address of the authoritative domain name server corresponding to the domain name.

Step 3: After obtaining the address of the authoritative domain name resolution server, send a domain name resolution request to the address, and the authoritative server finally responds with the IP address of the corresponding domain name.

Local DNS cache (Host)

After the domain name resolution service is divided into layers, the availability and reliability are very high, but as a client, if I have to request the domain name server to resolve the IP address for every request, it will affect the website access performance too much. Therefore, the client adds a layer of cache in its own locality. Every time a domain name request is made, it will first check whether there is a cache for the domain name from its own local cache. If there is, it will be obtained directly from the cache. ask.

DNS proxy cache (local DNS server)

The client's local cache can only be used on one computer, and these cached data cannot be shared. Is there a wider range of cache, so there is a local DNS server, and the local DNS server acts as an intermediate between the client and the DNS server A layer of proxy, the domain name resolution request of the same network operator will be sent to the local DNS server, and then the local DNS server will interact with the global DNS domain name resolution server, and the local DNS server will cache the corresponding IP of the resolved domain name, When there is the same domain name resolution request next time, the world will return the data in the cache.

As shown in the figure above, now we have obtained the most general process of DNS domain name resolution. This resolution process will go through the local cache, local DNS server, root domain name server, top-level domain name server, and authoritative domain name server. From the DNS resolution principle and process, we can also learn the design idea of ​​a high-performance and high-availability system. From DNS design, we can learn how to improve system performance and availability through multi-level shunting and multi-level caching system design .

DNS for load balancing

In the DNS server, the domain name and IP mapping relationship we configure can be modified at will. From this perspective, the domain name is not only easy to remember, but also isolates users from changes, because the server IP may be changed frequently. However, if the server changes after having the domain name, you only need to modify the mapping of the domain name to the IP.

另外一个方面,一个域名也可以配置多个IP, 不同的客户端请求DNS服务器可以解析到不同的IP,那从这个方面来看,那这就可以作为一种负载均衡机制,可以通过域名映射来实现流量分发,另外当一个IP对应的服务器故障时,我们可以通过删除对应的IP映射即可,新的域名解析就获取不到发生故障的IP了,从这个角度来看也保证了系统的可用性。

还有一种更智能的映射方式,我们可以在本地DNS服务器实现一些特殊的程序功能(内部负载均衡 SLB),通过SLB处理一些智能化的功能,在SLB里通过识别客户端的一些特性,实现智能的域名解析,比如不同地区的客户端,我们就返回给离客户端最近的IP。


参考文档:

分流篇-DNS分流

Guess you like

Origin blog.csdn.net/juanxiaseng0838/article/details/128706991