Linux DNS cache, NSCD service

Source: Internet
Author: User

Linux DNS cache, NSCD service

These two days to do stress test, found that with webbench pressure domain name than the pressure IP address several times slower, and pressure domain name when nginx concurrency is also very low. Repeated tests many times, suspect time is spent on DNS resolution. Do manual parsing in/etc/hosts:

1

echo "211.157.145.103 m.app518.com" >>/etc/hosts

After the pressure, the speed is normal.

Why is DNS parsing slow? What is the difference between Linux DNS caches? Check the Internet, find out that Linux itself is not a DNS cache, and want to use the DNS cache, you need to install a service program NSCD (Name Service cache daemon).

1

Apt-get Install NSCD

Modify the configuration file/etc/nscd.conf, turn on the DNS cache, modify this line

1

Enable-cache hosts Yes

This service can cache passwd,group,servers in addition to the DNS cache. The cache for these things is temporarily unavailable.

Restart NSCD Service

1

Service NSCD Restart

After the discovery does not need to do manual parsing, the access speed up to use the same IP address.

The role of the DNS cache on the server

When you need to interact with the outside world by domain name, the DNS cache comes in handy, which reduces the time for domain name resolution and improves efficiency. For example, the following conditions:

Using crawlers to capture page data on the Web,

Use the AUTH2.0 protocol to obtain user data from other platforms (such as Weibo or QQ)

Using a third-party payment interface,

Use SMS Channel to send SMS and so on.

How much performance can the DNS cache improve?

The first thing to look at is the ability of the network and DNS servers, the slower the DNS resolution, the greater the benefits of the DNS cache. For example, the DNS server 202.106.0.20 and Google's DNS server 8.8.8.8 in Beijing will be much slower.

If the DNS server is more stable, its effect on efficiency is a constant. How big is this constant?

I gave it a simple try. Stress test in LAN, press a static page under Nginx, use 202.106.0.20 this DNS server without DNS cache. An average of one minute can be accessed 270,000 times. Press a simple PHP page, The average one minute can be accessed 220,000 times. With the NSCD service, the static page can be accessed 1.2 million times a minute on average, more than 4 times times faster. The average PHP page can be accessed 500,000 times a minute, faster than a few times.

If it is a search engine or some kind of agency services, such as SMS channel, data push service, this performance improvement is quite considerable. But in a typical project, a server that makes 220,000 requests per minute is rare, so this performance boost is also slightly smaller.


This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1790309

Linux DNS cache, NSCD service

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.