]> git.ipfire.org Git - thirdparty/pdns.git/commit
dnsdist: Reduce memory usage with fast-changing dynamic backends 15472/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 25 Apr 2025 11:53:11 +0000 (13:53 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 25 Apr 2025 11:53:11 +0000 (13:53 +0200)
commit100c826a03fb9b27730117ee0bc8042a1645f70f
treeda508fb311fb01945b01cd5c7866dd5fa6fdff87
parentcb460fbe30c4a562cba6a92078d41415e701684c
dnsdist: Reduce memory usage with fast-changing dynamic backends

The Lua code in `dnsdist-resolver.lua` periodically check whether
the IP addresses associated with configured backend names have changed,
and if they have it does potentially remove backends whose IP addresses
are no longer present, and adds backends for new IP addresses.
Each backend configured in DNSdist uses a fair amount of memory
because of the states we pre-allocate for UDP queries, and unfortunately
it looks like Lua holds to removed backends for quite a while by default,
causing the removed backends to actually co-exist in memory with the new
ones for a long time, leading to a higher than necessary memory consumption.
This is particularly problematic when you realize that the memory allocator
usually hold onto memory even when the program releases it.
So in environments where IP addresses are updated very often, DNSdist can
consume several times the memory it actually needs, which is not nice.
This commit forces Lua to do a garbage collection cycle after refreshing
servers, thus releasing removed servers much more quickly. This is far
from ideal, but I don't have a better idea yet.
dockerdata/dnsdist-resolver.lua