Peaks in excessive consumption of: zone-sync

I have machines that randomly receive warnings about memory usage spikes exceeding 90%. I created a workgroup and was able to identify the process causing these spikes.

They are IPFire cards with 2GB of RAM. The profile of one of them is:

And what causes it:

-------------------------------------------------------------------
Sospechoso principal: PID 30441 usando 963 MB de RSS
  Comando: zone-sync --quiet --path=/var/lib/knot-resolver/zones --secure --primary=xfr.dbl.ipfire.org phishing.rpz.ipfire.org malware.rpz.ipfire.org
===================================================================

I’m leaving both logs (from two different IPFire servers) in case anyone else has this problem.

mem-watchdog - Bilon.pdf (61,8 KB)
mem-watchdog - Kalean.pdf (67,9 KB)

Would it be interesting to study it? Should I open a Bugzilla file?

Let me know.

Regards.

I think, it depends.

2GB is a very small RAM ressource, if you use components with automatic update functions. To achieve minimal off-times of the services, it is necessary to download the update data as whole. This is implemented with storage in RAM, either direct or indirect to temp files.

If we want a solution capable to use ‘large’ lists with small RAM, this behaviour is a bug. If we request a minimum memory space of 4GB for using large block lists, temporary high memory consumption is just an ‘issue’.

One aspect should be investigated. If the memory usage reaches 90% the system may use swap space. Is it released afterwards? Are other services urged to use swap?

Hi @bbitsch.

I only have the Malware and Phishing lists enabled in the DNS Firewall.

I understand that 2GB of RAM might be a small amount, but that’s what we have. These are peak usage spikes. Couldn’t the download speed be optimized so that these devices, even if the process takes longer, don’t require as much RAM?

You know the saying, “time vs. speed.”

Perhaps the downloads are all being attempted at once, which is why it’s taking so long. Perhaps each list could be updated sequentially, and that way, although it might take a little longer, we wouldn’t have this problem. (I don’t know how it’s designed; perhaps it does it sequentially. I don’t know.)

One IPFire:

Other:

And other:

Thanks.

There is a --parallel option that controls how many zones are processed simultaneously. I believe the default value is 1.

You can check the available options with:

zone-sync --help

Usage: zone-sync [OPTION...] ZONE [ZONE...]

      --debug                Run in debug mode
      --parallel[=N]         How many zones to process simultaneously
      --path[=PATH]          Path where to store the zones
      --primary[=HOSTNAME]   The hostname of the primary to fetch from
      --quiet                Run in quiet mode
      --secure               Use a secure transport to transfer the zone
  -?, --help                 Give this help list
      --usage                Give a short usage message
  -V, --version              Print program version

It might be worth checking whether the --parallel value is set to more than 1 ?

With DNS Firewall and Intrusion Protection System and web proxy, you will likely not have enough memory with 2 GiB.

With 2 GiB you might even find that running IPS makes the system use swap space regulary.

On my IPFire Prime system with 2GiB I have disabled IPS as the system was regularly using swap and periodically maxing the swap space and then getting an OOM.

You could also try disabling DNS Firewall and enabling urlfilter on the web proxy with the IPFire DBL selected for the source.

That might work for filtering with less memory usage.

zone-sync does have --parallel set to 1 by default. However I suspect that an increase in the --parallel value would require even more ram memory than a setting of 1

zone-sync appears to use four worker processes by default when running dnsctrl sync-rpzs.

Would it be possible to provide an option to reduce the number of parallel workers on systems with limited resources ?

dnsctrl sync-rpzs

[root@ipfireTest ~]# htop

PID USER       PRI  NI  VIRT   RES  PRIV S  CPU% MEM%   TIME+  Command
9561 knot-resol 20   0  171M 14716  4300 S   0.0  0.2   0:00.01 zone-sync ...
9562 knot-resol 20   0  170M 14212     0 S   0.0  0.2   0:00.00 zone-sync ...
9563 knot-resol 20   0  170M 14212     0 S   0.0  0.2   0:00.00 zone-sync ...
9564 knot-resol 20   0  170M 14212     0 S   0.0  0.2   0:00.00 zone-sync ...

Hello.

I’ve added the parameter “–parallel=1” to the IPFire files involved, and I think, as you mentioned, it has no effect.

That’s normal; it’s the default option.
But as @bonnietwin said…

Doesn’t this line of “–parallel=1” mean there’s only one worker?

No, it’s the number of zones loaded simultaneously
It doesn’t change the number of workers launched.

I tested also --parallel=10 and I still have 4 workers and more memory used.

[root@ipfireTest ~]#
 7570 knot-resol  20   0 1481M 1325M 1314M R  99.5 16.8  0:05.74 zone-sync --debug --parallel=10 --path=/var/lib/knot-resolver/zones --secure --primary=xfr.dbl.ipfire.org dating.rpz.ipfire.org games.rpz.ipfire.org streaming.rpz.ipfire.or
 7571 knot-resol  20   0  715M  558M     0 S   0.0  7.1  0:00.00 zone-sync --debug --parallel=10 --path=/var/lib/knot-resolver/zones --secure --primary=xfr.dbl.ipfire.org dating.rpz.ipfire.org games.rpz.ipfire.org streaming.rpz.ipfire.or
 7572 knot-resol  20   0  715M  558M     0 S   0.0  7.1  0:00.00 zone-sync --debug --parallel=10 --path=/var/lib/knot-resolver/zones --secure --primary=xfr.dbl.ipfire.org dating.rpz.ipfire.org games.rpz.ipfire.org streaming.rpz.ipfire.or
 7573 knot-resol  20   0  715M  558M     0 S   0.0  7.1  0:00.23 zone-sync --debug --parallel=10 --path=/var/lib/knot-resolver/zones --secure --primary=xfr.dbl.ipfire.org dating.rpz.ipfire.org games.rpz.ipfire.org streaming.rpz.ipfire.or

Perhaps what you’re running is launching without parameters? In other words, is it doing it by default?

Wouldn’t it be:


/usr/local/bin/update-rpzs

I think it executes this command and with it, the “--parallel=1”. I think. Perhaps this has nothing to do with it and I’m confusing apples and oranges (churras con merinas).

update-rpzs runs zone-sync with the following parameters:

# /usr/local/bin/update-rpzs
readonly ZONE_SYNC_ARGS=(
    # Be quiet
    "--quiet"

    # Output path
    "--path=${SYNC_PATH}"

    # Always use TLS
    "--secure"
)

For testing, I modified it as follows:

# /usr/local/bin/update-rpzs
# src/scripts/update-rpzs
readonly ZONE_SYNC_ARGS=(
    # Debug mode
    "--debug"

    # Parallel processing
    "--parallel=10"

    # Output path
    "--path=${SYNC_PATH}"

    # Always use TLS
    "--secure"
)

However, the number of worker processes launched remains four in both cases.
The --parallel option does not affect the number of zone-sync processes started.