Install and use ncsd for name service caching

According to Red Hat, "[t]he Name Service Caching Daemon (nscd) is a service that runs in the background and keeps a copy of /etc/passwd, /etc/group, [/etc/netgroup, /etc/services] and /etc/hosts files in /var/db/nscd/ directory. This can aid performance by reducing disk read overhead on a heavily loaded system dealing with many logins or name resolution requests."

The installation and usage is easy enough for a CentOS 6 install.

yum install nscd
service nscd start
chkconfig nscd on

This works right out of the box, however, there is a config file than can be edited (/etc/nscd.conf).  It can be read using the following command.

nscd -g

To test it.

time nslookup

To flush the cache.

service nscd restart