0

I understand that there is a comparison topic between the two modules here but this is different.

I was contacting cPanel support in order to help me freeing up some memory usage on the VPS. They found Apache 2.4 'httpd' child processes are using approximately 80MB RSS, while on their test server, a similar Apache 2.4 build only uses approximately 3MB RSS per Apache child process.

After discussing the issue for a while, they suggested switching to the Worker MPM in Apache 2.4 rather than using Prefork.

I searched for what they said, and found that Worker MPM use a less memory but it is not thread safe. Some other topics on websites tell that Worker will not work with php applications or mod_php. I'm not sure if this is correct or not.

I'm too confused what should I do? I have php scripts running on my accounts and don't want to interrupt any of them or get data corrupted.

What are your suggestions guys? Does switching to Worker MPM will solve the problem of running out of memory without interrupting php applications?

Is there any solution regarding the Apache usage? As 80MB RSS is too high comparing to the 3MB RSS.

closed as primarily opinion-based by Sven, MadHatter, Falcon Momot, Ward, rnxrx Jan 3 '14 at 5:29

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

2

If you have to use PHP as Apache module, you should go with Prefork, because as you said, PHP is compiled as not thread safe by default and Worker MPM is using threads.

If you can use PHP as FastCgi (PHP-FPM), you can use Worker MPM.

BTW Probably best way of deploying PHP today is using Nginx and PHP-FPM.

  • 1
    Can you expand on your last statement? Why is Nnigx + PHP-FPM best today? – Andrew Schulman Dec 29 '13 at 15:39
  • Apache with mod_php is quite efficient if you are serving only PHP scripts which is usually not the case. If you are serving the whole web application then you are starting bloated Apache processes (with PHP included) for all images, CSS ... as well. Then it can easily happed that Apache will consume all memory of the server and it will start swapping. In comparison Nginx is very lightweight and is not growing when more requests are coming. You can precisely configure PHP-FPM to use exact amount of resources not to overswap the machine. The only disadvantage is the overhead of fastcgi. – Daniel Milde Jan 25 '14 at 2:50
  • Mod_php is quite fast for running PHP, but it's higly inefficient when you serve some other files with Apache as well (CSS, JS, images). Apache processes with PHP embeded are memory demanding. Nginx is faster and more resource efficient than Apache with Worker MPM. – Daniel Milde Mar 1 '15 at 16:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.