Top Menu

Apache config for Worker MPM vs Prefork MPM

Some installations of Apache will have been compiled to work with either Prefork or Worker MPM, but most by default are compiled only to work with Prefork. Changing to Worker MPM may allow your server to handle much higher traffic, more user sessions, with less RAM use. Your site or server will not scale well if it is running Prefork MPM. Worker is a bit more difficult to set up properly, and has some restrictions regarding functionality of PHP scripts.

  • To determine which MPM is running:
    • If you see worker.c in the list of loaded modules, your Apache is running Worker MPM. If prefork.c, it is running prefork.
  • To determine if apache has Worker MPM compiled in:

    • If you see worker.c in the list of compiled-in modules, Apache can run Worker MPM.

Here is some useful info to help if your installation of Apache will work with Worker MPM:

  • Un-Comment HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd
  • restart apache
  • do some performance testing and raise your worker server and thread limits to sane levels in httpd.conf

If you need to recompile Apache and PHP, then you should do more research. Recompiling is not a trivial process.

I found that my server had much better memory usage under Worker MPM, however:

  • some scripts (squirrelmail, phpmyadmin) do not work on a per-domain basis and must be run direct to the actual server process with symlinked directories. This is much more efficient but less convenient for virtual domain owners
  • some /dev processes took on strange group permissions, getting the gid of the first user in the apache group.
  • browser caching was not well supported… the dreaded “blank screen between page loads” occurred more frequently under Worker MPM than Prefork MPM… also login/logout was sketchy on some sites… not sure why but my guess is that sessions may not be quite persistent using Worker vs Prefork due to cookie confusion… possible that multi-threading does not track cookies well.
More testing will be necessary to determine whether Worker MPM is a benefit on my server.

, , , , , , , , , , ,

2 Responses to Apache config for Worker MPM vs Prefork MPM

  1. aeomer September 20, 2012 at 7:51 am #

    Odd that you say you are having issues with cookies on worker mpm.
    I’ve never had nor had reported any issues with cookies using worker mpm both when I have a large number of worker mpm servers sitting behind a load balancer and just a single machine exposed directly to the web.

    You should not rely on Apache to do browser caching, especially as dynamic pages are now the norm.

    Important -
    1. Do not try to ‘convert’ a prefork apache to a worker mpm apache – always build from scratch. I would say your problems are related to this.

    2. Do not use mod_php with worker mpm. Instead use fcgi for more performance *and* removal of threading issues you may see with mod_php.

    Now the second note is contentious because mod_php does work multithreaded. However, some of the extensions do not play well with the worker-mpm/mod_php combination.

    Worker MPM is worth the hassle – running a site with 80K+ visitors a day on a modest four core 2.4GHz xeon with 8GB of memory and *no* memcache (where would it get the memory) attests to this.

    • Chris Gilligan September 20, 2012 at 10:26 am #

      Thank you for this info, I will revisit Worker MPM in a future build.

      Does it work well on a box serving several virtual domains?

      Lately I’ve been concentrating on NginX vs Apache.

Add Comment Register



Leave a Reply