Linux Open NSCD Service cache acceleration

Source: Internet
Author: User
Tags aliyun

In my use of the Aliyun host has observed the opening of a service NSCD, and later the Valley elder brother of the role of the service. Learn that NSCD caches three services passwd group hosts, so it records three libraries, corresponding to source/etc/passwd,/etc/hosts, and/etc/ Resolv.conf Store two caches per library, one to find records, and one to not find records. Each cache is saved with a live time (TTL). Its role is to increase the cache in this, speed up such as DNS resolution and so on.
I. Configuration of NSCD
By editing the/etc/nscd.conf file, add the following line to open the local DNS cache:
Enable-cache hosts Yes
The configuration on the Aliyun host is as follows:
[Root@361way ~]# cat/etc/nscd.conf
#logfile/var/log/nscd.log
Threads 6
Max-threads 128
Server-user NSCD
Debug-level 5
Paranoia No
Enable-cache passwd No
Enable-cache Group No
Enable-cache hosts Yes
Positive-time-to-live hosts 5
Negative-time-to-live hosts 20
Suggested-size hosts 211
Check-files hosts Yes
Persistent hosts Yes
Shared hosts Yes
Max-db-size hosts 33554432
The relevant parameters are explained as follows:
LogFile Debug-file-name
Specifies the name of the file to which debug information is written.
Debug-level value
Set the level of debugging you want.
Threads number
This is the number of threads that have started waiting for the request. The major general creates 5 threads.
Server-user User
If this option is set, NSCD will run as the user, not as root. If each user uses a separate cache (-s parameter), this option is ignored.
Enable-cache Service <yes|no>
Enable or disable the established service cache.
Positive-time-to-live Service Value
Sets the TTL (surviving time) of the item (successful request) that the service is in the specified cache. Value is in seconds. A larger value increases the cache hit rate and thus reduces the average response time, but increases the consistency of the cache.
Negative-time-to-live Service Value
Sets the TTL (surviving time) of the item that the service is negative in the specified cache (failed requests). Value is in seconds. If there are files that are owned by the UID (user ID) that is not in the system database (for example, when you unpack the Linux kernel source code as root), you should maintain a smaller value to reduce the cache consistency problem.
Suggested-size Service Value
This is the size of the internal hash table, and value should hold a prime to optimize the effect.
Check-files Service <yes|no>
Enable or disable checking for changes to files that belong to a specified service. These documents are/etc/passwd,/etc/group, and/etc/hosts.
Second, NSCD services view and clear
By default, the service is turned off under Redhat or CentOS and can be opened through services NSCD start. The cached DB file is under/VAR/DB/NSCD. You can view statistics by NSCD-G, which lists the sections:
[Root@361way ~]# Nscd-g
NSCD configuration:
5 Server Debug Level
34d 23h 14m 18s Server Runtime
6 Current number of threads
128 Maximum number of threads
0 number of times clients had to wait
No Paranoia mode enabled
3600 Restart Internal
5 Reload Count
passwd cache:
No cache is enabled
No cache is persistent
No cache is shared
0 suggested size
0 Total Data Pool size
0 used Data Pool size
3600 seconds time to live for positive entries
Seconds time to live for negative entries
0 Cache hits on positive entries
0 Cache hits on negative entries
0 Cache misses on positive entries
0 Cache misses on negative entries
0% Cache Hit Rate
0 Current number of cached values
0 Maximum number of cached values
0 maximum chain length searched
0 number of delays on Rdlock
0 number of delays on Wrlock
0 Memory Allocations failed
Yes CHECK/ETC/PASSWD for changes
................................................................................................
Clear Cache
Nscd-i passwd
Nscd-i Group
Nscd-i hosts
In addition to the above method, restart the NSCD service can also achieve the purpose of cleaning up the cache.
Third, the effect of NSCD
The first thing to look at is the capabilities of the network and DNS servers, and the slower DNS resolution is, the greater the advantage of DNS caching. For example, our DNS servers in Beijing 202.106.0.20 and Google's DNS servers 8.8.8.8 a lot of speed.
If the DNS server is more stable, its effect on efficiency is a constant. How big is this constant?
I tried it briefly. In the local area network to carry out the pressure test, pressure a nginx static page, using 202.106.0.20 this DNS server, without DNS caching. An average of 270,000 visits per minute. Press a simple PHP page, On average, you can visit 220,000 times a minute. With the NSCD service, the static page can be accessed 1.2 million times a minute, 4 times times faster. The PHP page can be accessed 500,000 times a minute on average, faster than a few times.
If you are doing a search engine or some kind of agent service project, for example, SMS channel, data push service, this performance improvement is quite considerable. But in a general project, a server 220,000 requests per minute is very rare, so this performance improvement also micro-call its micro.
But on the way to the limit, every little step is vital.

Related Article

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.