Skip to main content

Tuning the nscd name cache daemon

I've been playing a bit with the nscd now and want to share some tips related to tuning the nscd.conf file.

To see how the DNS cache is doing, use nscd -g.

nscd configuration:

0 server debug level
26m 57s server runtime
5 current number of threads
32 maximum number of threads
0 number of times clients had to wait
yes paranoia mode enabled
3600 restart internal

passwd cache:
no cache is enabled
[other zero output removed]
group cache:
no cache is enabled
[other zero output removed]

hosts cache:

yes cache is enabled
yes cache is persistent
yes cache is shared
211 suggested size <====
216064 total data pool size
1144 used data pool size
3600 seconds time to live for positive entries <====
20 seconds time to live for negative entries
66254 cache hits on positive entries
0 cache hits on negative entries
215 cache misses on positive entries
150 cache misses on negative entries
99% cache hit rate <====
7 current number of cached values <====
28 maximum number of cached values <====
3 maximum chain length searched
0 number of delays on rdlock
0 number of delays on wrlock
0 memory allocations failed
yes check /etc/hosts for changes

Check the cache hit rate.
If it's low, then if the 'current number of cached values' (here:7) is near the 'suggested-size' parameter (here:211), it means your cache is too small. Entries are being cached faster than they're being reused.
If 'maximum number of cached values' is near the suggested-size, there are periods when your system is caching a lot more than usual (check the current value) and you may need to tweak the suggested-size to slightly larger.
Also, the time nscd retains cache entries will be of influence on performance (here:3600 seconds). A lower value means an entry is cached briefly before flushing it and rerequesting a host from the DNS server. A high value means an entry can get stale, but more so for passwords than for hostnames. Nonetheless, lowering the value could free up the cache for new recent hostnames, instead of keeping old entries in the cache.
Any non zero value for 'memory allocations failed' may indicate your data pool is too small or the persistent store is running out of space. Or your system may simply be low on memory.
If you have some 'number of times clients had to wait', you could increase the number of threads. However, creating more threads means you'll handle more requests and your statistics will change. Both for the better or the worse! So recheck the stats afterward!

If you change parameters, it may be wise to clear (invalidate) the (persistent) cache using nscd -i {passwd,group,hosts}

Comments

Unknown said…
suggested-size cachename value
Sets the suggested number of hash buckets in the specified cache. This parameter should be changed only if the number of entries in the cache exceeds the suggested size by more than a factor of four or five. Since this is the internal hash table size, value should remain a prime number for optimum efficiency.

This attribute is obsolete and will be silently ignored. nscd now automatically adjusts the hash table size.
Dreams said…
Thanks for the tip!
Do you know off-hand from which version on this is true? Either way, the 4-5 factor is good to know.

Popular posts from this blog

Preventing PuTTY timeouts

Just found a great tip to prevent timeouts of PuTTY sessions. I'm fine with timeouts by the host, but in our case the firewall kills sessions after 30 minutes of inactivity... When using PuTTY to ssh to your Linux/Unix servers, be sure to use the feature to send NULL packets to prevent a timeout. I've set it to once every 900 seconds, i.e. 15 minutes... See screenshot on the right.

Setting up SR-IOV in RHEL6 on PowerEdge servers

Dell Community : "RHEL 6 provides SR-IOV functionality on supported hardware which provides near native performance for virtualized guests. Single-Root I/O Virtualization (SR-IOV) specification, introduced by PCI-SIG details how a single PCIe device can be shared between various virtualization guests. Devices capable of SR-IOV functionality support multiple virtual functions on top of the physical function. Virtual Function is enabled in hardware as a light weight PCIe function. Operating System cannot discover this function as it does not respond to the PCI bus scan and requires support in the host’s driver. As in PCIe pass-through, a Virtual function of a SR-IOV capable card can be directly assigned to the guest operating system. A virtual function driver running in the guest manages this device."