2

I have a question about nginx tune.

I have an application which I want execute 200 times every second.

I created bash file and used wget with bqO switch for execute.

But it has a problem.

When the number of requests is greater than 100. nginx not responses to another request and stuck into loading until one request done.

However I set pm.max_children and set worker_connections to 200.

Do you have a any suggest for solve this or is there any tuner like "MySQL Tuner" for tune nginx.

my configs: php-fpm55.conf:

pm = ondemand pm.max_children = 1024 pm.start_servers = 20 pm.min_spare_servers = 20 pm.max_spare_servers = 35 pm.max_requests = 256 pm.process_idle_timeout = 20

net.core.somaxconn=4096

sysctl.conf:

  • net.ipv4.tcp_window_scaling = 1
  • net.core.rmem_max = 16777216
  • net.core.wmem_max = 16777216
  • net.ipv4.tcp_rmem = 4096 87380 16777216
  • net.ipv4.tcp_wmem = 4096 65536 16777216
  • net.ipv4.ip_local_port_range = 1024 65000

nginx.conf:

  • worker_processes 8;
  • worker_rlimit_nofile 1024000;

events {

  • worker_connections 10240;
  • use epoll;
  • multi_accept on;

}

  • sendfile on;
  • keepalive_timeout 2;
  • types_hash_max_size 2048;
  • server_tokens off;
  • client_max_body_size 1024m;
  • client_body_buffer_size 128k;
  • server_names_hash_bucket_size 128;
  • server_names_hash_max_size 10240;
  • fastcgi_buffers 8 16k;
  • fastcgi_buffer_size 32k;
  • fastcgi_connect_timeout 300;
  • fastcgi_send_timeout 300;
  • fastcgi_read_timeout 300;

result: ab -n 100 -c 10 myindex.php

Server Software:        nginx
Server Port:            80
Document Length:        3 bytes

Concurrency Level:      10
Time taken for tests:   21.128 seconds
Complete requests:      100
Failed requests:        32
   (Connect: 0, Receive: 0, Length: 32, Exceptions: 0)
Total transferred:      17500 bytes
HTML transferred:       515 bytes
Requests per second:    4.73 [#/sec] (mean)
Time per request:       2112.791 [ms] (mean)
Time per request:       211.279 [ms] (mean, across all concurrent requests)
Transfer rate:          0.81 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:    19 1334 2747.0    144   15734
Waiting:       19 1334 2747.0    144   15733
Total:         19 1334 2746.9    144   15734

Percentage of the requests served within a certain time (ms)
  50%    144
  66%    549
  75%   1281
  80%   1700
  90%   4095
  95%   8790
  98%  12579
  99%  15734
 100%  15734 (longest request)
4
  • Much better than your previous attempt at the same question - you need to at least show your config.
    – AD7six
    Mar 14, 2015 at 16:35
  • you can see my config Mar 14, 2015 at 16:56
  • You should look into your PHP application, and look why the requests are taking such a long time. The performance is mostly affected by the application code itself. Mar 14, 2015 at 23:59
  • plz check result ab -n 100 -c 10 myindex.php Mar 15, 2015 at 5:56

2 Answers 2

2

You seem to be obsessed with nginx tuning while not even knowing which part of your architecture is the slowest. It's very unlikely that nginx would be the first thing to tune.

Put your fastcgi targets in one upstream block and append $upstream_addr and $upstream_response_time to your log format. If not already present, append $request_time to your log format then compare both times. If they are close to each other, your app is the culprit. If not then it's either nginx or your network.

Only after you got this information it will be potentially relevant to tune nginx.

0

Maybe you are interested in keepalive_requests ? The default value is 100, you can change it to a higher value

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .