Translate

Wednesday, 23 April 2014

Improving name resolution performance

AIX 6.1 introduced the netcd daemon which caches protocol (e.g. DNS) resolutions. It is started by the SRC (System Resource Controller) from "/etc/rc.tcpip", however it is normally commented out/disabled and won't run unless you create a configuration file. The default file is "/etc/netcd.conf"

A really basic example is:

# cat /etc/netcd.conf
cache  all  protocols   600  1440
This caches all protocol resolutions with a hash table of 600 lines for 24 hours.

Once the file has been created you can activate the daemon after each reboot by editing the "/etc/rc.tcpip" as follows:

# Start up netcd daemon
start /usr/sbin/netcd "$src_running"


To manually start the daemon enter:
# startsrc -s netcd

To query it's status:
# lssrc -l -s netcd
Subsystem         Group            PID          Status
 netcd            netcd            12255406     active
Debug                     Inactive
Configuration File        /etc/netcd.conf
Configured Cache         local protocols
Configured Cache         dns protocols
Configured Cache         nisplus protocols
Configured Cache         nis protocols
Configured Cache         ulm protocols




The “/etc/netcd.conf” file has four different types of configurations:
_ Caching settings
_ Security settings
_ Log level settings
_ Daemon settings

The /etc/netcd.conf file has four different types of configurations:

1. Caching settings: You can specify what resolver should be cached:

    # cache <type_of_cache> <type_of_map> <hash_size> <cache_ttl>
    (default setting: cache all all 128 60)
    (example for a DNS cache: cache dns hosts 128 0)

type_of_cache                  Declares the type of cache. Possible values are all, local, dns, nis, nisplus, and yp.
type_of_map                    Declares the map to be used to do the lookup. Check netcd.conf man page or look at the sample file for a complete list.
hash_size                           Specifies the number of lines used for the cache. (An hash table is used to store the cache)
cache_ttl                            Declares the time to life for a cache entry. The unit is minutes. The TTL is not used for local resource caches.
If you specify a value other than 0 for DNS caches, it will overwrite the TTL of the DNS server response.

2. Security settings:
You can specify under which user and group a netcddaemon should be run. The default user is root and the default group is system.

3. Log level settings:
The netcddaemon creates a log file in /var/tmp/netcd.log. You can specify a different log file location, a log file size limit in KB, and the number of log file rotations. The default setting is no size limit and therefore no rotations are taken.

    Use this syntax to change the settings:
    log_file <file>
    log_rotate <number>
    log_size <number>
 
4. Daemon settings
net_scan_frequency      Specifies how often netcddaemon looks for expired cache entries in network caches. The unit is min., default is 1.
local_scan_frequency    Specifies how often the netcddaemon checks for changes to the local resources. The unit is minutes, default is 1.
socket_queue_size       Indicates the message queue size. The unit is the number of outstanding requests, default value is 256.

Dump cache content

With the netcdctrl command you can dump the cache contents to a file. The dump can be either in binary or ascii format. To dump the DNS cache in ASCII format use the following command:

# netcdctrl -t dns -e hosts -a /tmp/netcd.cache.out

Displaying caching stats with netcdctrl

# netcdctrl -t dns -e hosts -s /tmp/netcd.stats
# more /tmp/netcd.stats
CACHE dns, hosts, name
Hash index : 0, Max number of entries : 0, Current number of entries : 0



No comments:

Post a Comment