A lot of users look to run Apache’s mpm_worker rather than the prefork mpm as it’s regarded to be much more efficient than the perfork mpm. Add in FastCGI rather than mod_php and it’s a great combination of stability as well as performance. Unfortunately there is one issue with running this on OpenVZ and that is the stack size. Even the modest VPS with very little traffic will end up using it’s allowed memory as well as it’s burst memory. Many suggest just not running mpm_worker with OpenVZ but this is not the best solution. The problem has to do with the default thread stack size of 8MB which with OpenVZ becomes real memory rather than simply virtual that will not actually be used by the system unless necessary. There are several easy fixes for this:
The first one is to modify the init.d script of Apache to reduce the stack size. So for a cPanel system it’ll be located at /etc/init.d/httpd and you’ll want to add the following:
ulimit -s 256
This will make the stack size just 256KB which will suffice for most users. I prefer to just do this with Apache but if you like you could modify this globally by changing /etc/security/limits.conf or for all services you could change /etc/init.d/rc . I believe though the best action is to just change Apache until you run into an issue with another service having the same issue. As you may not want just 256 but higher for a specific service or the defaults are fine in other cases and lower may reduce performance.
Well I hope that helps everyone out to get the performance of mpm_worker while not having to deal with the memory issues with regards to the default stack size.