Earlier quoted context omitted.
Thanks. I'm hoping people learn more about PHP-FPM too. It's a deadly combo with nginx.
Maybe, but we run Python :-)
NGINX + PHP-FPM + APC = Awesome
11–19 of 19 posts
Re: NGINX + PHP-FPM + APC = Awesome
#12I was on board until I read this: "For starters, with mod_php, each request that Apache handles loads PHP - and all of it’s libraries." No, it doesn't. In fact, that's a distinct advantage of mod_php. Everything is loaded and in memory when the request comes in. Throw APC on top of that and your code is also already compiled. The only way that would not be true is if you've got MaxRequestsPerChild tuned really low an…
"In fact, that's a distinct advantage of mod_php. Everything is loaded and in memory when the request comes in. Throw APC on top of that and your code is also already compiled." I would love it if someone cleared a very basic doubt of mine : If php is compiled, then what is the advantage of other programming languages? Wouldn't it be the same as anything else (except maybe considering the size of the language)? Is it…
IIRC the compiler for PHP uses a scheme compiler as a backend.
Re: NGINX + PHP-FPM + APC = Awesome
#13Earlier quoted context omitted.
"In fact, that's a distinct advantage of mod_php. Everything is loaded and in memory when the request comes in. Throw APC on top of that and your code is also already compiled." I would love it if someone cleared a very basic doubt of mine : If php is compiled, then what is the advantage of other programming languages? Wouldn't it be the same as anything else (except maybe considering the size of the language)? Is it…
If PHP is compiled, then it still has almost the same benefits and drawbacks compared to all the other languages, except for one: once it's compiled, PHP runs faster than it does when interpreted. Simple. IIRC the compiler for PHP uses a scheme compiler as a backend.
Re: NGINX + PHP-FPM + APC = Awesome
#14Earlier quoted context omitted.
If PHP is compiled, then it still has almost the same benefits and drawbacks compared to all the other languages, except for one: once it's compiled, PHP runs faster than it does when interpreted. Simple. IIRC the compiler for PHP uses a scheme compiler as a backend.
So then APC + PHP == (compiled python) == (compiled ruby) == C ? Sorry am not a python or ruby person so don't know how compiled code works out there.
For example, PHP's variables can be a string of any size, or a number, or an object, and you can change its type while the program is running. The compiler doesn't optimize the code execution as easy as, say, in Java. You can not allocated the minimum amount of memory that will store the variable values, for example.
Re: NGINX + PHP-FPM + APC = Awesome
#15However, 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.
Re: NGINX + PHP-FPM + APC = Awesome
#16Earlier quoted context omitted.
Maybe, but we run Python :-)
Are you using nginx for static files and proxying apache for python? I recently set something like that up and posted about it to spread the word. http://codespatter.com/2009/04/23/how-to-speed-up-your-djang...
Re: NGINX + PHP-FPM + APC = Awesome
#17I've been using this setup, except with XCache instead of APC. Does anyone know enough about the differences between the two to say if this is better or worse?
For an app I was testing it out on, it seemed to be about the same.
FWIW, Facebook uses APC.
Re: NGINX + PHP-FPM + APC = Awesome
#18I've been using this setup, except with XCache instead of APC. Does anyone know enough about the differences between the two to say if this is better or worse?
Re: NGINX + PHP-FPM + APC = Awesome
#19Earlier quoted context omitted.
Are you using nginx for static files and proxying apache for python? I recently set something like that up and posted about it to spread the word. http://codespatter.com/2009/04/23/how-to-speed-up-your-djang...
No apache. Nginx is talking to Django over a Unix file sock with fastcgi.