I recently updated devilbox from 1.6 do 2.2.0 and I found out that now bind uses over 700MB of RAM (!).
Why? Previously it was much less.
1ba685b017a9 devilbox_bind_1 0.00% 731.6MiB / 1GiB 71.44% 22.4kB / 32.4kB 115kB / 28.7kB 122
What is the command used to display the usage?
I installed more memory to my server (232GB, previously it was 64GB), and now bind takes over 1GB:
b87cc27463b6 devilbox_bind_1 0.00% 1.093GiB / 228.2GiB 0.48% 8.72kB / 0B 7.7MB / 28.7kB 122
some there must be something wrong with bind container config.
when I entered the bind container and run top I see this:
Mem: 53727200K used, 144252144K free, 83144K shrd, 4125812K buff, 39745012K cached
CPU: 0% usr 0% sys 0% nic 99% idle 0% io 0% irq 0% sirq
Load average: 0.06 0.08 0.52 2/2545 261
PID PPID USER STAT VSZ %VSZ CPU %CPU COMMAND
1 0 named S 1438m 1% 59 0% /usr/sbin/named -4 -c /etc/bind/named.conf -u named -f
255 0 named S 2592 0% 52 0% bash -l
261 255 named R 1608 0% 53 0% top
shouldn’t be max-cache-size defined in /etc/bind/named.conf.options ?
I issued command inside bind container:
rndc flush
and RAM consuption dropper by 400MB…
rndc stats
cat /var/cache/bind/named.stats
++ Cache Statistics ++
[View: default]
0 cache hits
0 cache misses
0 cache hits (from query)
0 cache misses (from query)
0 cache records deleted due to memory exhaustion
0 cache records deleted due to TTL expiration
0 cache database nodes
67108864 cache database hash buckets
536895175 cache tree memory total
536895047 cache tree memory in use
536895175 cache tree highest memory in use
1088 cache heap memory total
1088 cache heap memory in use
1088 cache heap highest memory in use
[View: _bind (Cache: _bind)]
0 cache hits
0 cache misses
0 cache hits (from query)
0 cache misses (from query)
0 cache records deleted due to memory exhaustion
0 cache records deleted due to TTL expiration
0 cache database nodes
1024 cache database hash buckets
32452 cache tree memory total
32324 cache tree memory in use
32452 cache tree highest memory in use
1088 cache heap memory total
1088 cache heap memory in use
1088 cache heap highest memory in use
according to: 4. BIND 9 Configuration Reference — BIND 9 9.18.2 documentation
max-cache-size
This sets the maximum amount of memory to use for an individual cache database and its associated metadata, in bytes or percentage of total physical memory. By default, each view has its own separate cache, which means the total amount of memory required for cache data is the sum of the cache database sizes for all views (unless the attach-cache option is used).
When the amount of data in a cache database reaches the configured limit, named
starts purging non-expired records (following an LRU-based strategy).
The default size limit for each individual cache is:
- 90% of physical memory for views with
recursion
set to yes
(the default), or
- 2 MB for views with
recursion
set to no
.
Any positive value smaller than 2 MB is ignored and reset to 2 MB. The keyword unlimited
, or the value 0
, places no limit on the cache size; records are then purged from the cache only when they expire (according to their TTLs).
What do you think should be a sane default value instead of the current 90% default?
How about setting it to 10MB ?
I’ve added a PR here: Adding MAX_CACHE_SIZE by cytopia · Pull Request #47 · cytopia/docker-bind · GitHub
As far as I’ve read now, the default is 90%
, so I set it to that value to keep backwards compatible with all the previous versions.
I tried bind-0.30 - it is a little bit better:
8c12c586bb6f devilbox_bind_1 0.00% 602.1MiB / 188.8GiB 0.31% 4.85kB / 0B 0B / 28.7kB 122
but still 600MB of RAM.
It is regardless of the MAX_CACHE_SIZE (I tried 1MB, 10MB, 100MB).
for 1MB - cache statistics are a lot smaller:
++ Cache Statistics ++
[View: default]
0 cache hits
0 cache misses
0 cache hits (from query)
0 cache misses (from query)
0 cache records deleted due to memory exhaustion
0 cache records deleted due to TTL expiration
0 cache database nodes
16 cache database hash buckets
56305 cache tree memory total
24263 cache tree memory in use
56177 cache tree highest memory in use
2176 cache heap memory total
1088 cache heap memory in use
2176 cache heap highest memory in use
[View: _bind (Cache: _bind)]
0 cache hits
0 cache misses
0 cache hits (from query)
0 cache misses (from query)
0 cache records deleted due to memory exhaustion
0 cache records deleted due to TTL expiration
0 cache database nodes
16 cache database hash buckets
56302 cache tree memory total
24260 cache tree memory in use
56174 cache tree highest memory in use
2176 cache heap memory total
1088 cache heap memory in use
2176 cache heap highest memory in use
++ Cache DB RRsets ++
But there must be also something else…
Hmm, that is indeed strange. I also didn’t find anything else yet, that I could configure to bring the memory down.
top shows:
CPU: 0% usr 0% sys 0% nic 99% idle 0% io 0% irq 0% sirq
Load average: 0.12 0.14 0.10 3/2556 272
PID PPID USER STAT VSZ %VSZ CPU %CPU COMMAND
1 0 named S 925m 0% 56 0% /usr/sbin/named -4 -c /etc/bind/named.conf -u named -f
266 0 root S 2596 0% 38 0% bash -l
272 266 root R 1608 0% 41 0% top