Slow sites with mpm_prefork

Ubuntu:20.04

Our sites are very slow when many join.
We now have mpm_prefork and php-fpm7.4.
Desirable would be mpm_event and php-fpm7.4.
How can we get it without risking the server crashing?

Server will crash under high load only if you run out of memory and there is too much disk thrashing.

I was mentioning in an earlier post that I have hosted on a Virtualmin server lots of WordPress website for a computer training institute for students to use while they learn website design.

The load on the server for most hours of the day is minimal but for the two hours in a day when the course is being conducted, over 100 students log in simultaneously and carry out the same operations as the trainer instructs the group - hence at such times there is lots on activity on the server in terms of memory usage, web and db server access and disk i/o.

How we were able to avoid slowdown is to insure that there is no disk thrashing and memory is released quicker than usual by php-fpm.

Hope this helps you with tweaking your server for better performance under high load.

1 Like

Switching to the event MPM should be painless. There are oodles of tutorials on this subject in Ubuntu land, for instance here and here.

When making the change the only interruption should be the time Apache is down which should only be a minute or two. If PHP-FPM hasn’t crashed the web server with the prefork MPM loaded, switching to the event or worker MPM can only turn out for the better.

2 Likes

Thank you both.
Switching to the event MPM went well.

Did it make it notably faster? (I bet it didn’t make a very big difference, but I’m curious.)

I think it’s better. However, not quite as good as I hoped.
CPU load averages is now between 1 and 2 when traffic is normal.
But that’s the best configuration you can have, right?

1 Like

The web server is almost never the bottleneck; the hardware is so fast today that web servers don’t have to try hard to server thousands of requests per second. So, if your site is slow, look to the application and its use of the database first. (Unless you’re serving thousands of requests per second, in which case you have bigger problems to solve.)

Sometimes, there can be resource contention, for example open files limits or other user limits…and raising those can help with slowness. Sometimes there are other “silver bullet” solutions. But, usually when a site is slow, you just have to turn on slow query logging, and start fixing the application to be more efficient and better tuned for your workload (or throw more hardware at it). Tuning the database memory limits and other tunable values may also give some small wins.

But, looking at the web server as a source of “fast” or “slow” is not usually a good use of time. Though it’s also usually not terribly time-consuming to switch to event (or other) MPM or to make some minor tweaks to suit your workload and available system resources (you can sometimes get a little gain from knowing how many CPU cores you have, how much RAM you have, setting various limits higher, etc.).

So, yes, event MPM is good, if you can safely use it (i.e. not using mod_php). It is slightly more efficient both in terms of memory and in evident CPU load (but “load” is a complicated thing to read…more processes produces more “load” even if what they’re waiting on and limited by isn’t really the CPU). But, it’s probably not going to solve performance problems with your sites.

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