nsd3 eating up memory after update to wheezy (version 3.2.12-3)
Recently I've updated the nsd3 server to wheezy version. I was surprised about its quite big memory usage.
306 ? Ss 0:00 0 181 4034 268 0.2 /usr/sbin/nsd -c /etc/nsd3/nsd.conf 308 ? S 0:00 0 181 10694 196 0.1 /usr/sbin/nsd -c /etc/nsd3/nsd.conf 309 ? S 0:02 0 181 4238 304 0.2 /usr/sbin/nsd -c /etc/nsd3/nsd.conf
25941 ? Ss 0:00 0 206 51389 42156 32.1 /usr/sbin/nsd -c /etc/nsd3/nsd.conf 25946 ? S 0:00 0 206 58049 24372 18.5 /usr/sbin/nsd -c /etc/nsd3/nsd.conf 25947 ? S 0:00 0 206 51389 23964 18.2 /usr/sbin/nsd -c /etc/nsd3/nsd.conf
I've figured out that the reason for this is the new feature called Response Rate Limiting aka RRL. The default configuration defines quite large hashtable, which is eating up more memory.
rrl-size: <numbuckets> # This option gives the size of the hashtable. Default 1000000. More buckets use more memory, and reduce the chance of hash collisions.
By reducing the the rrl-size one can easily lower the memory usage by nsd3. I've played a little bit with the configuration and looked at the biggest virt memory size as shown by ps ax v. The image below graphically presents the increase of the memory usage with rrl-size.
Depending on your response rate limiting needs, set rrl-size accordingly.
The following rrl options could also be interesting (see man page for details):
rrl-ratelimit rrl-whitelist-ratelimit rrl-whitelist