I've been using nginx as a static file server and a reverse proxy to apache mod_php for a while now and it's been great. I had some time to experiment with the full monty of nginx recently on a development box. I thought I'd share some of my simple benchmarks vis-a-vis my old setup, and also pose a question re: a problem I've encountered. First the benchmarks:
|Run||VIRT||RES||SHR||DAT||50% response time|
|mod_php w/ apc||~75M||25-27M||~14M||18-22M||250ms|
|nginx php-fpm w/ apc||~72M||20-25M||13M||14-20M||270ms|
For the above:
- max fpm children = max apache clients
- ab -c5 -n10000
- address tested is the front page of a drupal6 instance on localhost with ~80 modules installed including cck, views, ubercart, and two large custom application-specific modules written by yours truly
- Server caching (e.g. nginx microcache) and Drupal page caching turned off
- APC is fantastic (we knew that already).
- mod_php is slightly faster at php than php-fpm, though the difference is small. This is consistent with what I've read elsewhere.
- php-fpm uses less RAM than mod_php (~3-5M less per process in this test, which is not insignificant).
Couple these results with nginx superiority at static file serving and other goodies, and now that fpm is baked into php itself, I think I'm going to go ahead with this setup on production. For those that want to stick with apache, I should also point out that you can use fastcgi instead of mod_php with apache as well, which will cut down on apache memory use vis-a-vis static file serving considerably.
I do, however, have one problem. For some reason all my links include index.php. So instead of "http://localhost/?q=node/15", I get "http://localhost/index.php?q=node/15". Drupal6 won't let me enable clean URLs. I'm pretty sure this is a problem w/ my nginx config, as this issue isn't occuring w/ apache. Interestingly, it also isn't happening with a drupal7 instance under nginx, just drupal 6.
I'm using perusio's config for nginx, with microcaching turned off. This appears to be a rewrite issue, but I can't put my finger on it. Among other things, I tried:
- disabling any drupal modules (such as Global Redirect) that might cause problems
- adding an explicit base url to "settings.php"
I'd greatly appreciate any ideas on how to fix this. I feel I'm missing something pretty basic!