Wordpress filled all RAM with no website

Hello,
I have debian 8 with virtualmin, but I think I have problem with RAM.

I had to remove 3 website (wordpress) because apache2 has gone “out of memory” and tables has been “broken”

Now I have only 1 website to test, with only one page, fresh install, but still RAM is increasing hour by hour. Now have:

6141 www-data 506.32 MiB /usr/sbin/apache2 -k start
6144 www-data 506.29 MiB /usr/sbin/apache2 -k start
6142 www-data 506.1 MiB /usr/sbin/apache2 -k start
6143 www-data 506.09 MiB /usr/sbin/apache2 -k start
6140 www-data 506.08 MiB /usr/sbin/apache2 -k start
8313 www-data 506.08 MiB /usr/sbin/apache2 -k start
435 www-data 506.01 MiB /usr/sbin/apache2 -k start
437 www-data 506.01 MiB /usr/sbin/apache2 -k start

free -m
total used free shared buffers cached
Mem: 1962 1509 452 122 103 973
-/+ buffers/cache: 431 1530
Swap: 0 0 0

I have set php7.4 fastCgi

Hi,

There are many reason why this could be happening.

I would at first looked at mpm_event_module:

Try tweaking defaults, I would start from:

MaxConnectionsPerChild 0

… and set it to 10 for now, restarted Apache and tried to see how it behaves. I would also tried FPM mode for running scripts.

1 Like

I have only “mpm_prefork_module”
I put to 10 and now I’ll see next 24 hours. (no visits into website, apart me and bots)

maybe I have to change to event or workers?
https://www.woktron.com/secure/knowledgebase/133/How-to-optimize-Apache-performance.html

edit:
I edited with: https://askubuntu.com/questions/453377/how-to-enable-event-mpm-apache-2-4-on-ubuntu-14-04-with-thread-safe-php
and now I have event instead prefork.
seems to go better, I have few processes and less memory “cached”. Maybe I’ll try to re-enable other website with traffic

I was able to enable “mpm_event”, but then I had some Wordpress critical errors.
Maybe “mpm_event” is less compatible with plugins than “mpm_prefork”?
“Mpm_worker” is better for wordpress?

I think any of the multi-process models should work if you’re using PHP-FPM. mod_php cannot work with anything other than prefork (because of thread safety issues). I don’t know about fcgid. But, I doubt you need to change anything from the defaults (prefork).

Are you sure this is a problem and not just buffer/cache expanding to fill all RAM? (see https://www.linuxatemyram.com/ )

You clearly have free RAM in the above free -m and buffer/cache is also using some of it. 2GB is pretty small, if you’re running mail.

Also, you should look at top for a better idea of memory usage…the process list in Webmin shows the virtual memory size, but not resident size (I’ll ask Jamie to add res, as it’s more relevant information). Those Apache processes can share a lot of memory, because it’s mostly shared libraries. For example our Apache virt size is about 650MB and res size is only ~17MB. Big difference.

Finally, add a swap file. Hopefully nothing ever needs to swap out, but it can help prevent errors or services being killed by the OOM killer in the event of temporary memory usage spikes.

1 Like

Thanks, for now 2 website are working with this solution, better than prefork.
I disabled the plugin that was having problems.

Provider (OVH) showed from control panel an use of 90% when I had 3 website. I thought that Virtualmin allocates still all the RAM and then “manage it”. Is not?

For now I have few few mail, clamscan have “only” 100MB, SQL have 800MB because I set him to 1GB (medium size from wizard setup)

Maybe using CDN is a good idea for saving resources?
I had a free account on cloudflare for 2 of 3 websites

Should I have a schedule for “reboot” of server? Or could be it “always online” without create problems?

This is the RAM since last reboot (yesterday 17.40)


Still rising

Virtualmin does not “manage” RAM usage of anything other than itself (the management UI provided by Webmin and its modules), and even that isn’t really managed, so much as “this is what Perl allocated automatically for the data structures we created”.

Most memory usage comes from the services Virtualmin manages.

clamscan is definitely using more than 100MB (just reading the AV database into memory takes 640MB last I checked), even if only for a couple of minutes each time a new mail comes in. You can’t reasonably run ClamAV on a server with only 2GB of memory, if the server is doing much else. I’d recommend you either disable clam or increase RAM, if you care at all about performance or if you’re running low on memory.

CDN is nice, but it won’t solve severe lack of memory caused by running ClamAV with low memory.

How can I disable ClamAV?
If I uninstall it then maybe I’ll have problem with “Check Configuration” of Virtualmin

If memory serves me right you should be able to do that by re-running the install wizard under System Settings.

Yes, but I cannot set ClamAV on/off
If your system is going to host domains that will receive a large amount of email, scanning incoming messages for viruses can generate high CPU load. This is due to CPU use by the ClamAV virus scanner when it is started, which can be avoided by running the ClamAV scanning server clamd in the background. This consumes RAM, but reduces CPU load and makes mail processing faster.
However, Virtualmin does not know how to enable the ClamAV server scanner on your system. You will need to set it up manually.

Also Should I have scheduled reboots? Or server should run always and “auto-set” processes and RAM?

I have installed php-fpm and then was there as module. then I was able to activate the module

No need to run the postinstall wizard. You can turn off Virus filtering in System Settings->Features and Plugins.

The setup wizard is just combining a bunch of options from a variety of places into one to be easier for new users. You never have to use it after the first time (though it’s harmless to use it again, as long as you set the options the way you like and don’t change them to something that confuses you). But, there’s always a way to set just the one option you want to change without having to go through the wizard.

Thanks, I found it, but:
Failed to save enabled features : The feature Spam filtering cannot be disabled, as it is used by the following virtual servers : X,Y,Z

edit:
I resolved with this: https://www.virtualmin.com/node/15911

Also, I have noticed that after php update the RAM dropped from 30-40% to 25% (500MB free on 2GB). Why? Maybe I have to reboot once a day? (in this case I have not rebooted since past week)

hi, that is for just one wp site running? I think its way too much. Check your database tables, theme code, plugins. I run couple sites based on wp (currently 7) and my current stats after reboot 9 months ago are:

Real memory: 3.78 GiB total / 2.5 GiB free / 2.04 GiB cached Swap space: 4.56 GiB total / 4.09 GiB free

Do you have swap partition (or file) as well on your system? I am also up to date (yet still on older but still supported debian 9) and I generally reboot only once a year or when I do distro upgrade. Normally I would not need to reboot at all.

Edit: that is combination of ssd and sshd (ssd for / and /swap and sshd for /home)

Wow,
I have 2 WP website “normal” with few visits (mostly bots) and 1 WP new website with 0 visits and one landing page.
I had 1 WP with 6k articles and 25MB of database, but I had problems and I removed that (before I had to switch to mpm_event).
Now webmin says: 20% of real RAM and free -m:
total used free shared buffers cached
Mem: 1962 981 980 86 54 351
-/+ buffers/cache: 576 1385
Swap: 3063 0 3063

@wolfseo well I should be honest with you, I did banned all bad bots from visiting my sites with fail2ban however I have from about 40k visits via all sites, my blog on my main site is visited most due to some tech help information but thats all… I have no comments and I check database tables once a year as well… you know wp updates and other stuff can actually make your db run slowly, eating the ram also crash the whole thingy… however I did coded my themes by my self… so its very clean code without errors… plus most of the plugins I replaced within my theme php code so I end up not using any plugin at all… sites run faster then normal sites however I am less close to be hacked as less bloatware running on top of the wp it self.

once again in your phpmyadmin check your db tables and if there is any issues fix them (there is somewhere button to do it) also check plugins…anything you not use, just remove it. I do not use any cmd. I would say unless you have massive issues, you dont have to reboot often, however consider update from 8 to 9 and then to 10… be informed that configs from 8 regards the apache changed a lot… same for dbases and from 10 theres no 5.xx php… I mean if you do clean install you may run only php7.xx but if you do distro upgrade, you should have php 5.xx at least at 9… I have it right now… anyway wp is php7 okay, you safe to upgrade.

My biggest db currently is 700MiB and it runs smoothly - as I can tell.

I think you have problem with db or php… wp should not eat that much ram at all. I am on gpl and wp was installed manually but even pro version would install it as I did…

edit: here is terminal output of free -m command:

Last login: Sat Jan 25 11:43:52 2020 from 192.168.1.1
root@host:~# free -m
              total        used        free      shared  buff/cache   available
Mem:           3876         963         497         107        2416        2523
Swap:          4676         473        4203
root@host:~# 

I can see swap is used but since its ssh its fast almost as ram I would say :wink:

thanks,
I have php 7.3, but I dont know which bot are good, because most of them are from google, fb, yahoo.
maybe you refer to failed login, but those are other bots. my stats were from CDN, that I used to have

now I have:
[root@vps775525 ~]# free -m
total used free shared buffers cached
Mem: 1962 1027 934 102 61 389
-/+ buffers/cache: 575 1386
Swap: 3063 0 3063
[root@vps775525 ~]#

I have 0 swap now, similar to you but with few websites