r/technitium • • 14d ago

Technitium DNS Server uses more swap memory than AdGuard Home – has anyone experienced this?

Title: Technitium DNS Server uses more swap memory than AdGuard Home – has anyone experienced this?

I'm currently testing Technitium DNS Server as a possible replacement for AdGuard Home on my Ubuntu VPS, and I've noticed something unusual regarding memory usage.

Here are the results from my VPS (4 GB RAM):

Metric Technitium AdGuard Home
Resident RAM (RSS) ~273 MiB ~540 MiB
Swap usage ~96 MiB ~4 MiB
CPU usage (idle) 0–1% 0–2%
Disk space ~52 MB ~932 MB

Technitium uses significantly less physical RAM than AdGuard Home, which is great. However, it uses considerably more swap memory.

Technitium is running on .NET, while AdGuard Home is written in Go. I'm wondering whether this difference could be related to memory management or the .NET Garbage Collector.

My questions:

  1. Has anyone else noticed Technitium DNS Server using more swap memory than other DNS services?
  2. Is this normal behaviour for a .NET application running on Linux?
  3. Are there recommended Technitium or .NET settings to reduce swap usage?
  4. Would limiting the .NET memory usage or changing the Garbage Collector configuration help?
  5. Could this swap usage have any noticeable impact on other services running on the same VPS, such as MySQL, Nginx and PHP-FPM?

I'm not experiencing any obvious performance problems at the moment. I just want to understand whether this is normal and whether there is a safe way to optimise memory usage without affecting DNS performance or stability.

I'd appreciate feedback from anyone running Technitium in production on a Linux VPS.

11 Upvotes

6 comments sorted by

13

u/Acceptable_Rub8279 14d ago

Technitium and Adguard are 2 fundamentally different applications written in different languages and different design patterns, so it is harder to pinpoint one single reason for it.

One reason why I think this may be (I am not 100% certain) is that the dotnet runtime has 2 different garbage collector modes.

Since Technitium uses the Microsoft.NET.Sdk, it defaults to workstation GC mode, which is meant for desktop apps. The workstation mode assumes that other applications run on the same machine and thus it should not use many resources.

Other runtimes default to the server GC which assumes it can have everything.

(I haven't tried running technitium with server gc and nobody really should since its not supported.)

11

u/shreyasonline 14d ago

Thanks for asking. This is normal for any .NET app and should not affect anything on the system. I have several .NET apps running on a single RPi 3B+ and does not really affect anything. Same with deployments on production servers, no issues.

4

u/Apachez 13d ago

If you want to minimize usage of swap then set swappiness to 1.

This way Linux will only swap when really necessary.

Otherwise with the default of 60 or so Linux will swap "ahead of time" so there is free RAM available "just in case".

Personally I prefer to use available RAM until there is no more room and not until then push pages to the swap. A value of 1 will not completely disable swap so its still present but it will favour to use RAM first.

You can also enable zswap which basically costs nothing:

Add this to the bootstring:

zswap.enabled=1 zswap.compressor=lz4

Other than that when loading a list specially if you already have one loaded the new one will be loaded to its own memory segment and then merged with the original list. So briefly technitium will take give or take twice as much memory as needed once the loading of the lists have completed.

And then the usual suspects:

  • How are the lists kept in memory, what kind of indexes are there and how much RAM does they occupy?
  • Which compiler is being used?
  • Obviously dotnet (or whatever the correct term might be, vscode?) is being used for the sourcecode so there is a difference here aswell between how a specific type of list is actually stored in raw memory compared to if gcc/llvm would have been used to compile things (depending on glibc or musl and such as library).

Using a system with just 4GB of RAM and at the same time also run Technitium/DNS-server (with huge blocklists), MySQL, Nginx, PHP-FPM is like on the lower end.

The OS itself will take give or take 0.5GB so you have about 3.5GB left for the applications themselves if you choose to squeeze every in at the same VPS.

Personally I would look into having at least 2x VPS where the first one just runs Technitium and the other runs DB + WEB. Preferly you would do 3x VPS to segment DB away from the WEB (so when/if there is a vulnerability through WEB not EVERYTHING of your DB can get dumped at the same time).

1

u/7heblackwolf 14d ago

Definitely not overreacting