Wordpress website <200 visit per day consume 1.5gb ram constantly

Use php-fpm and tweak it to release memory quicker than usual.

I tried to apply modifications as suggested by link you provided.

By default, virtualmin is using mpm_event, but using FPM dynamic instead of ondemand as suggested on by tecmint.
I believe 10s timeout to kill fpm children is enough to reduce RAM usage.

After restarting FPM & Apache, RAM usage reduced to 700M compared to 100-200M of other user running single wordpress which I believe it is fair, however after few hours, it climbed back to 1.1G.

I have never liked WP Rocket. To me it caused far more problems than it cured.

Also, are you using Cloudflare?

I would ditch WP Rocket and get Hummingbird.

If you’re using not using Cloudflare, you may want to consider it. It works very well with Hummingbird and after some time of caching your site you’ll see the memory usage drop a good bit.

Check out this page and see if it may be something that might interest you.

1 Like

Yes.

The user I mentioned in question is not using any caching plugin, it only use cloudflare as proxy and cache. Thus makes wp plugins irrelevant.

Edit: I included the other VPS with wp rocket as comparison. So I believe it is not because of caching plugin.

You may be right. But:

If you don’t coordinate the Rocket caching with the Cloudflare caching you wind up with conflicts on the cache purge, so you wind up holding on to a bunch of files you shouldn’t be holding on to which…

wait for it…

increases your memory usage exponentially.

The user I mentioned in question is not using any caching plugin, it only use cloudflare as proxy and cache. Thus makes wp plugins irrelevant.

This is likely why you’re having problems. Caching in WP is relevant even if you’re using a CDN. My favored combination is WP Super Cache combined with Autoptimize. Also remove any unused plugins and themes.

Continuing the discussion from Wordpress website <200 visit per day consume 1.5gb ram constantly:

It looks like community here is focused to caching plugin that I mention for comparison. The main question is about an account, that does not use any 3rd party caching features from plugins or CDN.

My main concern is, it is unusual for an account with less than 200 visit daily combined from all 6 wordpress sites, exhausting resources on 2vcpu and 4gb ram VPS as quoted below:

What should I look for reducing this issue?

For starters, you could run top and check which processes consume most of your resources. Also, I would switch from Apache to Nginx if I were you. I have seen dramatic improvement in performance (RAM as well as CPU) when I switched to Nginx but that’s more or less an ime/imo though.

And with regards to the top suggestion above:

  • If you see a bunch of PHP processes consuming excessive RAM, then you would need to tweak your PHP configuration accordingly. Depending on your sites’ traffic as well as on other factors like your sites’ theme structure and plugin settings, I would recommend using a mix of dynamic, static and ondemand. I would also recommend setting up and configuring OPCache in your PHP config.
  • If you see MySQL/MariaDB consuming excessive RAM, then you would need to tweak your database configuration accordingly.
  • If you see some other process(es) consuming excessive RAM, post a snippet of the results here and maybe someone could help with narrowing the cause down.

@technicalw above as all experts here said, check your php code for old or shit code practices, same for js and if you use jquery same for that… once you are sure your code is running clean and within standards enable gzip if you did not already… then focus on databases… select, repair, optimize - read outputs it will tell you what is bad and what was done… if some plugin, better remove it asap and replace by your own code or another plugin.

I hope it did helped.

1 Like

In this server (now upgraded to higher 4vcpu 8gb ram) running htop command:

  • 7 named user with 4.1% mem with /usr/sbin/named -u named -c /etc/named.conf command
  • 30ish mysql process (may reflect number of virtual server) with /usr/libexec/mysqld --basedir=/usr command
  • then followed with 2.2% usage from /usr/lib/systemd/systemd-journald
  • then 30ish miniserv 1.1% processes.

Does it looks like I have bad database config problem?

Are they consuming abnormal resource % though?

That has to be some theme or plugin you’re using doing that. It just has to be.

Wordpress has pretty much dropped the ball entirely on maintaining standards on themes and plugins. There are a lot of “free” themes out there that will rack up so many mysql requests it can shut you down on some service providers. I’m talking into the 10’s of thousands of requests per hour.

Utility plugins are the same. Some of the free caching plugins are simply horrible.

By comparison, my main site is just a forum these days; no Wordpress at all. (It runs Xenforo) I get between 250 - 350 unique visitors a day. My memory usage on that site never gets above 150 to 200 MB at any given time.

You need to start looking at which apps are racking up the most requests. I’m willing to bet you’ll find it’s either a theme you’re using or some sort of caching program or other utility plugin.

Look also in LOG files, eventually set them to display/log also warnings.

Maybe you can see there more information.

Can you post output of this command please:

ps aux | grep “php”

Since above you’ve posted just a top processes using certain percentage of memory. On the other hand you can have 200 processes running and using just a bit of memory each and they just might be php processes.

In addition to that it might be good idea to post here your servers .conf file, just as someone above mentioned it, you might want to tweak it to get better results, probably change 9999 setting to something much lower or make tweaks to use ondemand instead of dynamic. Since you are probably high on php processes.

Conf files are probably located here /etc/php-fpm.d/ or for your PHP version, they should be here /etc/opt/remi/php74/php-fpm.d/ but it completely depends on your PHP setup. This is just a wild guess.

FWIW, Virtualmin.com gets (a lot) more visitors than that, running WordPress and WooCommerce, using basically a stock Virtualmin PHP-FPM configuration, and isn’t using an inordinate amount of resources (virtualmin 5 0 329.9M 399.8M 837.3M to compare apples to apples with the same smem command).

So, I think I want to blame one of your WordPress plugins, as others have done. I didn’t do any tuning, beyond giving MariaDB a bit more cache and buffer space.

I tend to want to suggest you turn on slow query logging in your database, and see if you can spot what’s working a lot and holding connections open for a long time. Turning off less critical WP plugins is also a good idea to help narrow down the problem.

High memory usage can be a symptom or a cause, and it’s hard to know which it is without figuring out exactly what’s chewing it up.

1 Like

I’m not sure about abnormal resource %. All showing same % of process somewhere between 4.1% and 2.2% as it is sorted by %mem usage.

I may read htop wrong, can I read it as below?

  • 7 x 4.1% = 28.7%
  • 30 x (mysql process, lets assume each is 3%) = 90%
  • 1 x 2.2 % = 2.2%
  • 30 x 1.1% = 33%
  • with total memory usage 153.9%

it is here:

root     3863507  0.0  0.0 221932  1124 pts/0    S+   15:23   0:00 grep --color=auto “php”

I’m not sure if it is wise to post all those comments on www.conf file at /etc/php-fpm.d/ so I trimmed all comments here

[www]
user = apache
group = apache
listen = /run/php-fpm/www.sock
listen.acl_users = apache,nginx
listen.allowed_clients = 127.0.0.1
pm = ondemand
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.process_idle_timeout = 10s
pm.max_requests = 500
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache

I just tried to run smem -uk -s rss again and here is 2 biggest number sorted by RSS value

threesix     12        0   345.5M   382.0M   692.8M 
root       246     4.6G     2.8G     3.3G     5.6G 

threesix user is the user that have 6 websites. Root taking 5.6G RSS is suspicious for me.

You may be reading things wrong, here. Many processes (e.g. PHP or Apache) will be sharing much of their memory used via shared libraries. You can’t just add them up.

threesix looks fine, to me, I think. That’s about what you’d expect for a WordPress+WooCommerce+other modules installation.

root is maybe large. But, that includes MySQL, which can be quite large depending on your configuration.

1 Like

for 200visits per day, why use 50 max children? a value of 5 or 10 should be enough… eg config.
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 100

other options :
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
are not used when pm is ondemand, you can remove those.

from a brief reading of case, you might have issues with your themes/plugins as well, you might need to look at mysql, apache logs for errors…
i would also dump cloudflare, never understood why people use those “net bullies”. they slow down your site, 3rd parties should be avoided unless absolutely necessary…

1 Like

This is a shared server. One virtual server have 200 visits per day. is 5 max_children is for each virtual server?

Free plan from Cloudflare helped to increase GPS and GT Metrix score for me. Do you have better alternative?

Doesn’t MySQL have it’s own user? Why is it using root account too?
I cannot find big memory usage from htop interface for root account. How can I found out what process is eating that much memory?

depends on traffic and on host resources… on some sites with more traffic, i use bigger values.

better score doesn’t always mean faster website. speed ratings algorithm will give additional points for using a CDN/cloudflare. but from my personal experience, if your visitors come from just one country/continent, then you’re probably slowing down your page with using any such 3rd parties.

another point is visitor’s privacy. you’re giving away your visitors’ personal data to these 3rd parties… (so, if you come to think about it, nothing’s really free from Cloudflare, Google, etc…).