During the stress tests of the linux dns cache and NSCD service over the past two days, it was found that using webbench to press a domain name is several times slower than that of an IP address, and the nginx concurrency is also low when the domain name is pressed. I tested it multiple times and suspected that the time was spent on dns resolution. manually parse in/etc/hosts: 1echo... during the stress tests of the linux dns cache and NSCD service over the past two days, it was found that using webbench to press a domain name is several times slower than that of an IP address, and the nginx concurrency is also low when the domain name is pressed. I tested it multiple times and suspected that the time was spent on dns resolution. perform manual parsing in/etc/hosts: 1 echo "211.157.145.103 m.app518.com">/etc/hosts and press it again. The speed is indeed normal. why is dns resolution slow? What is the difference between linux dns cache? I checked through the internet and found that linux itself has no dns cache. if you want to use dns cache, you need to install a service program NSCD (name service cache daemon ). 1apt-get install nscd modify the configuration file/etc/nscd. conf, enable dns cache, and modify this line of 1enable-cache hosts yes. in addition to dns cache, this service can also cache passwd, group, and servers. the cache for these items is temporarily unavailable. restart the nscd service 1 service nscd restart and find that no manual resolution is required. the access speed is the same as the IP address. the dns cache function on the server is useful when the domain name needs to interact with external data. it can reduce the domain name resolution time and improve the efficiency. for example, when crawlers are used to collect page data on the network, auth2.0 protocol is used to obtain user data from other platforms (such as Weibo or QQ), and third-party payment is used. Interface, use the SMS channel to send text messages, etc. how much performance can the dns cache improve? First, we need to look at the capabilities of the network and dns servers. the slower dns resolution, the greater the advantage of dns cache. for example, the speed of our dns server 202.106.0.20 and google's dns server 8.8.8.8 in Beijing may be much worse. if the dns server is stable, the effect on efficiency is a constant. how big is this constant? I just tried it. perform a stress test in the LAN. press a static page under nginx and use the dns server 202.106.0.20 without dns caching. 0.27 million accesses per minute on average. press a simple php page and access the page 0.22 million times per minute on average. after the nscd service is added, the static page can be accessed 1.2 million times per minute on average, more than four times faster. on average, php pages can be accessed 0.5 million times per minute, more than once. if it is a search engine or a number of proxy service projects, such as SMS channels and data push services, this performance improvement is considerable. however, in general projects, it is rare for a server to send 0.22 million requests per minute, so this performance improvement is also slightly called. but on the way to the limit, every small step is crucial ~
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.