3 ms·
I generally agree with the advice in this article, excluding the bit about "each request that Apache handles loads PHP". nginx is glorious software, and the co
by jbyers 18y ago
I generally agree with the advice in this article, excluding the bit about "each request that Apache handles loads PHP". nginx is glorious software, and the combination of nginx / fastcgi / and APC work very well. At Wikispaces we serve over ten million PHP requests a day using a similar setup.
However, this article implies nginx is better than Apache for the wrong reasons. nginx has two critical advantages over Apache in this context:
- handling dynamic requests without tying up backends (buffering proxy server)
- serving of static files from disk without incremental memory use (event-driven vs. multi-thread or multi-process)
It may also be the case that nginx is marginally faster than Apache in pushing bits absent of these two issues, but in my opinion gains here are greatly outweighed by operational considerations (see below). I'd modify this article's advice to be:
1. serve all static requests using an event-driven webserver (nginx)
2. proxy all dynamic requests through a server that buffers backend results and spoonfeeds clients (nginx)
3. wrap your backend scripting or application server in the system that is easiest to understand, deploy, maintain, and troubleshoot (Apache and mod_php)
There are other choices here that may be as good or better in your environment, but with 1. and 2. in place, CPU/memory/IO savings by rejiggering 3. are minimal.
Operational Considerations: including but not limited to process management, logging, availability of value-add modules like mod_security, over-the-wire troubleshooting, HTTP load-balancing, and finally non-rarity of your solution. If plain fastcgi is a few percent faster than mod_php but orders of magnitude more rare, I'd happily forego the performance gain for the benefits of a larger install base.