I'm a little confused between the different MPMs offered by Apache - 'worker', 'event', 'prefork', etc.
What are the major differences between them, and how can I decide which one will be best for a given deployment?
There are a number of MPM modules, but by far the most widely used (at least on *nix platforms) are the three main ones:
It's probably not advisable to use prefork unless you need a module that's not thread safe.
Use if: You need modules that break when threads are used, like
Don't use if: Your modules won't break in threading.
Use if: You're on Apache 2.2, or 2.4 and you're running primarily SSL.
Don't use if: You really can't go wrong, unless you need prefork for compatibility.
However, note that the treads are attached to connections and not requests - which means that a keep-alive connection always keeps ahold of a thread until it's closed (which can be a long time, depending on your configuration). Which is why we have..
The exception here is with SSL connections; in that case, it behaves identically to worker (gluing a given connection to a given thread until the connection closes).
Use if: You're on Apache 2.4 and like threads, but you don't like having threads waiting for idle connections. Everyone likes threads!
Don't use if: You're not on Apache 2.4, or you need prefork for compatibility.
In today's world of slowloris, AJAX, and browsers that like to multiplex 6 TCP connections (with keep-alive, of course) to your server, concurrency is an important factor in making your server scale and scale well. Apache's history has tied it down in this regard, and while it's really still not up to par with the likes of nginx or lighttpd in terms of resource usage or scale, it's clear that the development team is working toward building a web server that's still relevant in today's high-request-concurrency world.
|show 1 more comment|
Mostly depends on which Apache modules you want to use. I think worker is generally the default choice, but some (older) modules require forking and depend on prefork.
If you have no preferences, I recommend you go with the preferred dependency from your OS distribution. Ubuntu for example will by default install mpm-worker when you install Apache2.