Apache comes in a few different flavours. The two most common are pre-forked (multi-process) and multi-threaded (worker).
If you're doing lots of little static connections, threads would be lighter and faster. If you just have few big apps constantly spawned, prefork might have an edge due it's maturity and stability.
The multi-threaded version often faster and takes less memory. Apache must fully support a multi-threaded environment. Modules that are not 100% thread-safe can cause Apache to crash or behave strangely. The pre-forked version takes more memory. In a VPS, like your Zerigo Server, memory’s usually a fairly important concern. However, the pre-forked version also alleviates the need for modules to be fully thread-safe.
In general, I recommend using the multi-threaded version of Apache only if you are confident that all of the rest of your software stack will support it. If it won’t, or you’re just unsure, then you should run the pre-forked version. Using more memory is definitely better than having things crash or be otherwise unstable.
One of the most common add-on modules, PHP, has some thread-safely problems. To be fair, the core of PHP is supposed to be fine in a multi-threaded Apache. However, some of the third-party libraries used by PHP are not thread-safe. This has the downside of needing to use the pre-forked version of Apache if you plan to use PHP running from inside Apache as a module (using mod_php, which is by far the most common way of running PHP).
When running PHP via mod_php, choose pre-forked. When running only static files (html, jpg, etc), choose multi-threaded. If passing on to a backend application server like Mongrel (for Ruby on Rails), the multi-threaded version works fine.
If you’re mixing and matching uses and even one use, in one virtual host, requires the pre-forked version, then pre-forked will need to be your choice.
If you want all the available server resource put to the best use and get the best performance out of your server, you could switch to worker from the default prefork.
If you would rate stability more, then you would rather prefer prefork to worker.
The decision actually is not that obvious. It warrants expertise, and in-depth analysis of your exact requirements.
No comments:
Post a Comment