Why do you want to do domain name resolution
Use the domain name is for users to more friendly access to the target site, such as you want to visit Baidu to search some of the things you want, you are www.baidu.com easy to remember, or remember 61.135.169.121 this IP easy, it is obviously the former. But for the computer, direct access to the IP address will be faster and more efficient, because the domain name needs to be resolved by the DNS server, and finally converted to an IP address. Domain name resolution This process needs to spend 20~500ms, 500ms is what concept ah, the radius of the earth is 40,000-kilometer, the transmission of electrical signals in the fiber is about 200000km/s,500ms an electrical signal can be around the earth to run 2.5 laps, visible domain name resolution of how low efficiency.
The process of domain name resolution
We look at the entire process of parsing the www.kuwo.cn domain name through a dig command that comes with Linux.
Executed under Linux: $ dig +trace www.kuwo.cn, execution results such as:
We take steps to see
- The first step is to obtain the IP address of one of the 13 root nameservers worldwide, because the IP of the 13 root nameservers is fixed, so it does not take extra time. The IP obtained in this example is: 192.168.210.118
- The second step is through the root domain name server: K.root-servers.net. CN. The IP address of the domain is: 193.0.14.129, which costs a total of 226ms.
- The third step through the CN domain Name server: a.dns.cn. Gets the IP address of the kuwo.cn. Domain name: 203.119.25.1, a total cost of 4ms.
- Fourth step through the ns4.koowo.com domain name server to obtain the WWW host IP address: 60.29.225.22, a total cost of 1ms.
This is the whole process of domain name resolution, spending 231 milliseconds, time is relatively long.
How to optimize Domain name resolution
We know that domain name resolution is to convert the domain name into an IP address, and then communicate with the target host, so we just need to record the corresponding IP address of the domain name, the next time directly use, you do not need to go on the above so complicated steps.
Add the following tags to the
How to view the status of a domain name resolution
In Chrome we can see the use of domain name resolution, including the percentage of domain names being cached, which domain names are parsed too long, etc.
In the address bar of the browser, enter: Chrome://histograms/dns. Prefetchqueue
The results are as follows:
Visible in my local system, 66.9% of domain names are used directly by the browser cache, no time spent
Front-end performance optimization-Domain name resolution