The subject of Apache 2/PHP was raised in the Slashdot discussion of the PHP5 beta RC a few days back. One comment [google.com] from a PHP dev (Rasmus) was:
Apache2 has a number of different modes it can work in. These modes are called MPM's. The default MPM is called Worker which is a multithreaded model. PHP, mod_perl, mod_python, and any other similar technology which links directly into the httpd processes will need to be perfectly threadsafe and reentrant to work effectively with a threaded Apache2 mpm. This is doable for the core of PHP, but there are literally hundreds of 3rd party libraries that can be linked into PHP and nobody whether or not these libraries are threadsafe. And figuring out if a specific library is threadsafe or not is non-trivial and it can very from one platform to another. And just to make it even harder, this stuff will appear to work fine until you put it under load or hit very specific race conditions which makes it nearly impossible to debug.
So, since we can't tell you for sure that a threaded Apache2 mpm + PHP will work we do not suggest you use it for a production server. And since we can't know for sure, none of the main PHP developers use this combination for our own servers which compounds the problem because it is not receiving anywhere near the amount of realworld testing required to work out all the little issues above and beyond this threading unknown.
There is an Apache2 mpm, called "prefork", which isn't threaded and basically makes Apache2 look like Apache1. But hey, we have a very good server already that looks like Apache1.
In the end I don't see Apache2+PHP ever becoming a production platform with the current architecture. The only way I see it ever working is to pull PHP out of Apache and use a fastcgi approach. Or, with time, perhaps we will learn how to make sure a library is perfectly threadsafe and safe to use in a multithreaded Apache2.
For now, I really see no reason not to simply use Apache1 if you want a robust, fast and stable web server.
One of the posters [slashdot.org] found this [php.net] more recent comment from Rasmus as well:
We are not talking about just Apache2 here. We are talking about Apache2+an MPM+PHP+3rd Party Libs. The folks at apache.org are only concerned with Apache2 itself, and for serving up static files it is better than Apache1 in many respects. However we have to worry about a lot more stuff here. In fact, we couldn't care less about serving up static files. The main issues as I see them are:
1. Thread safety issues. - It is very difficult to track down threading problems and we don't have decent tools to help us. The thread safety of many 3rd party libraries are unknown quantities and can depend on the OS, libc and even compile flags. - Many distributions seem to ship with the Worker MPM as the default and that is the MPM that gets the most attention. This is a hybrid multi-process, multi-threaded MPM.
2. You can eliminate the threading problem by running the prefork MPM which effectively makes Apache2 behave just like Apache1 in the way it forks processes and serves one request at a time per process. Issues here: - Apache2 itself is rather fringe still. It has approximately a 5% marketshare vs. 65% for Apache1 at the time of this and out of that I would guess the majority are running the Worker MPM. So we are talking about a fringe MPM in a fringe server. This means it has not had anywhere near the attention from people running large production web server farms that it needs for me to comfortably say that this is a solid piece of code with all the kinks worked out. - The benefits of moving to Apache2+prefork are questionable. The new filter API would be one of the benefits, but it still has some issues and by default we run PHP as a handler, not a filter currently. You can optionally run it as a filter but people have had problems with that.
Until such a time when enough clueful PHP people think there are enough realworld useful features in Apache2-prefork or even Apache2-threaded to actually sit down and bang away at PHP and the majority of the PHP extensions under Apache2. Or if enough regular users report back that they tried it and had absolutely no problems then we will change our reccomendation, but for the time being I don't think that we in good faith can tell users that Apache2+PHP is something they should be putting into production.
Apache2 itself is rather fringe still. It has approximately a 5% marketshare vs. 65% for Apache1 at the time of this and out of that I would guess the majority are running the Worker MPM. So we are talking about a fringe MPM in a fringe server.
In fact, Apache 2's default MPM [apache.org] on unix is Prefork [apache.org], which should work the same way as Apache 1.3, but with several improvements of Apache 2 [apache.org].
My personal opinion is that the PHP development team should tackle thread-safety, but even if they don't they should updat
You can eliminate the threading problem by running the prefork MPM which effectively makes Apache2 behave just like Apache1 in the way it forks processes and serves one request at a time per process.
I can't entirely agree with what Rasmus is saying here. The code for handling of the incoming requests in the MPM is entirely new, cleaner, leaner and better in every respect than Apache 1.
Also, what Rasmus is saying makes one believe that threading is what Apache 2 is all about. First, Apache 1 can be thr
I suppose that for thread-safe implementation one could look at AOLServer. While it won't address PHP issues (one can use PHP with AOLSErver all the same, but the same trhread-safeness argument applies), a built-in Tcl interpreter is probably more than enough to replace the LAMP (with LAPT (Linux/AOLServer/Postgres/Tcl):)).
"There are things that are so serious that you can only joke about them"
- Heisenberg
I've been running PHP/Apache 2 for a while... (Score:4, Interesting)
...and haven't noticed any problems. Why is this advised against?
Re:I've been running PHP/Apache 2 for a while... (Score:4, Informative)
One of the posters [slashdot.org] found this [php.net] more recent comment from Rasmus as well:
Re:I've been running PHP/Apache 2 for a while... (Score:2)
In fact, Apache 2's default MPM [apache.org] on unix is Prefork [apache.org], which should work the same way as Apache 1.3, but with several improvements of Apache 2 [apache.org].
My personal opinion is that the PHP development team should tackle thread-safety, but even if they don't they should updat
Re:I've been running PHP/Apache 2 for a while... (Score:2)
I can't entirely agree with what Rasmus is saying here. The code for handling of the incoming requests in the MPM is entirely new, cleaner, leaner and better in every respect than Apache 1.
Also, what Rasmus is saying makes one believe that threading is what Apache 2 is all about. First, Apache 1 can be thr
Re:I've been running PHP/Apache 2 for a while... (Score:2)