views:

59

answers:

1

Hi, here's a six core with 32GB ram. I've nginx 0.7.X and php5-fpm with php5.3 (from dotdeb.org). Important config files:

nginx.conf

user www-data;
worker_processes 2;
events {
    worker_connections 4096;
}
location ~ \.php$ {
                fastcgi_pass   unix:/tmp/fcgi.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
                include fastcgi_params;
}

php5-fpm.conf

<value name="listen_address">/tmp/fcgi.sock</value>
<value name="max_children">1500</value>
<value name="max_requests">5000</value>

that's all. with apache bench (ab -n 1000 -c 1000 http://url...) I can request a static file (size of 10kB) in 250ms for 1000 concurrent connections.

Document Path:          /inc/helper-swf.js
Document Length:        10217 bytes

Concurrency Level:      1000
Time taken for tests:   0.278 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      10448124 bytes
HTML transferred:       10219896 bytes
Requests per second:    3600.30 [#/sec] (mean)
Time per request:       277.755 [ms] (mean)
Time per request:       0.278 [ms] (mean, across all concurrent requests)
Transfer rate:          36734.70 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   27  11.1     30      41
Processing:    16  101  57.1    102     215
Waiting:       15  101  57.1    101     215
Total:         28  128  56.5    136     235

Percentage of the requests served within a certain time (ms)
  50%    136
  66%    167
  75%    178
  80%    184
  90%    198
  95%    205
  98%    220
  99%    228
 100%    235 (longest request)

But when request goes to a php file this tooks 500 ms??? Php does nothing, first line in file is a die();

Document Path:          /test.php
Document Length:        0 bytes

Concurrency Level:      1000
Time taken for tests:   0.501 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      158000 bytes
HTML transferred:       0 bytes
Requests per second:    1996.99 [#/sec] (mean)
Time per request:       500.754 [ms] (mean)
Time per request:       0.501 [ms] (mean, across all concurrent requests)
Transfer rate:          308.13 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   28   9.5     29      41
Processing:    15  365 117.4    395     448
Waiting:       15  363 117.1    393     448
Total:         27  393 122.9    425     480

Percentage of the requests served within a certain time (ms)
  50%    425
  66%    434
  75%    471
  80%    472
  90%    473
  95%    474
  98%    479
  99%    479
 100%    480 (longest request)

There is no content to transfer when accessing php file, there is only an upstream from nginx to php5-fpm via socket (tcp tooks 800ms with 1000 concurrent connections). What's the problem? There are no hints in logs. Open file limit is 32768. Is there a way to tune response time from php-fpm?

+2  A: 

The fastcgi loads also PHP instances. If your PHP is full of fat (extensions you don't need) then this is the result: higher times per request.

My advices are:

  • recompile PHP only with the extensions you are using
  • install APC
  • increase the buffers size
narcisradu
Might be worth compiling php as a static binary too - http://ez.no/developer/blog/php_as_dso_or_as_static_php_module
Kieran Allen
Hi, thanks for response. PHP is installed from dotdeb.org repository. Because we've like to have automated installation of server I don't like to build it on myself. APC is already installed and makes a plus of 20% in performance.What kind of buffers do you mean? FastCGI buffers?