Servers (BIND DNS/Maria DB) crashing randomly

Hi all,
I am facing an issue that I can’t solve.

Several times a week, the “BIND DNS Server” and “MariaDB Database Server” servers stop without me understanding why.

If I restart them manually (Virtualmin GUI or CLI), no trouble, they restart successfully.

I’ve been looking at log files a little bit in every direction without really finding a clue.
If I could already know at what time the crash occurs, it would allow me to know if it is potentially related to the backups, because the crashes occur mainly in the schedules of these.

Can you please help me to understand why these servers stop so frequently.
Thanks in advance for your advice.

SYSTEM INFORMATION
OS type and version CentOS Linux 8.5.2111
Virtualmin version 7.7

It’s almost certainly the OOM killer. MariaDB pretty much doesn’t crash.

Check dmesg for out of memory errors. Look at top to keep an eye on how much memory you’re using.

If you’re using clamscan (instead of clamdscan), that’s what’s doing it. There is no use case for clamscan for scanning mail today, it’s just too big. Starting it up for every email is a recipe for disaster no matter how big your server is.

1 Like

@Joe Thank’s for your time.
You’re right, this is the result for dmesg:

[Mon May 15 22:12:01 2023] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/system.slice/php80-php-fpm.service,task=php-fpm,pid=2114261,uid=1031
[Mon May 15 22:12:02 2023] Out of memory: Killed process 2114261 (php-fpm) total-vm:567468kB, anon-rss:28840kB, file-rss:4kB, shmem-rss:45000kB, UID:1031 pgtables:824kB oom_score_adj:0

My server got 6.4 GiB of RAM

free -h
              total        used        free      shared  buff/cache   available
Mem:          6.4Gi       4.1Gi       812Mi       784Mi       1.6Gi       1.3Gi
Swap:            0B          0B          0B

I’m just using my server as a webserver, no emails except Postfix to send outogoing emails.

I will now try to understand what causes this memory saturation.

How many websites?

I see the php-fpm maybe causeing alot of memory use.
Does restarting the fpm servers reduce memory alot?
I reduce my memory usage from over 60% to under 30% by add these FPM pool options in the template. Then on the servers disable and enable fpm to set the new settings,

The process that is killed is not necessarily (or even likely) the process that triggered the OOM killer. The kernel tries to choose the least important process (least recently active, probably?) to kill.

Which process was killed is probably not useful information in tracking down what is consuming all the memory.

OP, you need to watch top, as I suggested. Sort by memory with M.

How many websites?

Less than 50.
Some of them are only pre-prod websites and are not publicly accessible.

Does restarting the fpm servers reduce memory alot?

Yes … From ~60 % to ~30%, just like you.

Did I have to test you settings ?

pm = ondemand
pm.max_children 80
pm.process_idle_timeout = 10s
pm.max_requests 200

@Joe

As a safety measure, you could give yourself some breathing room by adding a swapfile (or swap partition). On small systems, double the RAM is a good choice, and on mid-sized systems like yours, the same amount of swap as RAM would be good. You don’t want to operate out of swap (I mean, if you find your commonly used services can’t run all from memory, you don’t have enough memory), but it can prevent occasional spikes of memory usage from shutting down vital services, things just get slow as stuff is swapped in and out, rather than the kernel having to kill something.

I don’t see anything obvious in your output. At the time of that screenshot, your system is running fine and you have 2.4GB of available memory. You’ll need to keep an eye on it to see what explodes in memory usage, or see what slowly increases in memory usage.

I don’t see a reason to blame php-fpm, which seems to be where you’re focusing, but it looks normal to me. It will naturally be a big part of your memory usage, because you have a bunch of sites and a bunch of php-fpm processes running, but unless you have some page or app that has memory leaks and/or forks a bunch of new processes what I see in your screenshot looks like any other shared hosting system with a bunch of sites and using php-fpm.

I got them from https://www.tecmint.com/improve-php-fpm-performance/
plus they where on the forum as well.
I added to template. Then disable and enable on one server and see how the website runs.
Seeing it in the template it only effects new servers and enable/disabling the fpm setting.
I did make a big difference to my memory consumption, I was constantly running 60% and higher with 15 sites and 4 gigs of ram.
With the new settings it rarely get over 30% now.
There are comments in the article that it slow end users. I haven’t seen that on the website I have. WP sites are up within 1 second.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.