Based on the descriptions for both the Prefork and Worker MPM, it seems the prefork type is somewhat outdated, but I can't really find a proper comparison of the two types.
What i'd like to know:
- What are the differences between the two versions?
- What are the (dis-)advantages of each server type?
- Are there any basic guidelines on which type to choose based on the conditions?
- Are there any big performance differences between the two?
As the docs say, you should use the prefork MPM if you need to avoid threading for compatibility with non-thread-safe libraries. Typically, any non-trivial Apache module (
mod_php
-- or, more precisely, the myriad of extensions and libraries that it links to -- being the canonical example) has some sort of non-thread-safe library (or has non-thread-safe code in it), so unless you're using a pretty stock Apache install, I'd go for the prefork MPM.The classic solution to running unsafe extensions while serving large numbers (>100) of concurrent connections is to run PHP on fastCGI (mod_fcgid, a native apache module) and proxy dynamic requests to that from an apache instance that runs the Worker MPM.
This would enable you to scale from a few hundred up to >1000 concurrent connections with a modest amount of memory (4~8GB) when serving a mix of static and dynamic content.
Of course, you should also investigate front-end caching solutions as part of your overall deployment (memcached, varnish).
Alternatively, upgrade to apache 2.4 and its native event MPM, which handles concurrency in a much improved fashion (threads are fired off upon connection, not waiting to be polled.)
It's been about 3 years since the question got posted but I would recommend you go with worker MPM instead of pre-fork even if using PHP, to get the better performance.
As to the differences, pre-fork is non-threaded hence the server forks a process for each client request (it pre-forks in anticipation of new requests so that forking doesn't eat into the response time). Since requests are server in a separate process, this usually taxes your memory and CPU a lot more than. The worker bring multi-threading which is lighter and has better memory utilization.
This is something very particular to what you're serving. 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. Why not just set up what you need, test one, swap out the MPM module, try it again, see which one suits you better?
that needs on the type and kind of traffic you will have. And also first you need to understand the main difference between the prefork and worker. Hope the below article will help you figure out! http://slashroot.in/how-is-nginx-different-from-apache