4

I'm running Drupal and trying to figure out the best stack to serve it. Apache + mod_php or Nginx + PHP-FPM

I used ApacheBench (ab) and Siege to test both setups and I'm seeing Apache performing better. This surprises me a little bit since I've heard a lot of good things about Nginx + PHP-FPM. My current Nginx setup is something that is a bit out of the box, and the same goes for PHP-FPM

What optimizations I can make to speed up the Nginx + PHP-FPM combo over Apache and mo_php ? In my tests using ab, Apache is outperforming Nginx significantly (higher requets/second and finishing tests much faster)

I've googled around a bit, but since I've never using Nginx, PHP-FPM or FastCGI, I don't exactly know where to start

PHP v5.2.13, Drupal v6, latest PHP-FPM and Nginx compiled from source. Apache v2.0.63

ApacheBench Nginx + PHP-FPM

Server Software:        nginx/0.7.67
Server Hostname:        test2.com
Server Port:            80

Concurrency Level:      25
---> Time taken for tests:   158.510008 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
---> Requests per second:    6.31 [#/sec] (mean)
Time per request:       3962.750 [ms] (mean)
Time per request:       158.510 [ms] (mean, across all concurrent requests)
Transfer rate:          181.38 [Kbytes/sec] received

ApacheBench Apache using mod_php

Server Software:        Apache/2.0.63
Server Hostname:        test1.com
Server Port:            80

Concurrency Level:      25
--> Time taken for tests:   63.556663 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
--> Requests per second:    15.73 [#/sec] (mean)
Time per request:       1588.917 [ms] (mean)
Time per request:       63.557 [ms] (mean, across all concurrent requests)
Transfer rate:          103.94 [Kbytes/sec] received
Rushi
  • 181
  • 6
  • 2
    In all honesty, it really would help if you provided some additional details regarding how you currently have things configured. Such configurations such as amount of listening processes, maximum requests per process, whether you have keepalives enabled, etc... all impact server performace. With your configuration files, we'd atleast have a good starting point to work from ;) – jonathanserafini Dec 25 '10 at 03:48
  • Wow, I never thought that Apache might be faster than nginx. Thanks for showing this. :) –  Jan 29 '11 at 04:03
  • Number of worker threads in both cases would certainly make a difference… how many were them? – lapo Jan 29 '11 at 08:42

2 Answers2

3

Here are some possibilities for this:

  1. You have enabled some kind of opcode cache with mod_php
  2. You have turned on mod_cache in apache
  3. You are using TCP connection method in php-fpm.

Post back with these details.

Also, try apache + mod_fastcgi + apc + php-fpm.

And, if you are using the if condition in nginx for rewrite rules, switch to try_files instead. if sometimes has performance issues.

Nilesh
  • 289
  • 1
  • 7
1

Is it possible that you have APC or another accelerator enabled with apache? I agree with the poster above that more information about your configuration is needed.

acrollet
  • 121
  • 1