0

php-fpm config :

  pm = dynamic 
  pm.max_children = 50 
  pm.start_servers = 20 
  pm.min_spare_servers = 10

and this is nginx config:

    root /var/www/html;
    index index.html index.htm index.nginx-debian.html;
    server_name _;
    location / {
            try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

But When I send 50 requests at the same time, it is executed one by one.

enter image description here

enter image description here

Jinnrry
  • 405
  • 1
  • 5
  • 18
  • I think the grey part of the request in the network log is stalled. If so then https://stackoverflow.com/questions/29206067/understanding-chrome-network-log-stalled-state is relevant, but the bottom line is it's not a PHP-FPM issue since the request hasn't actually hit PHP-FPM yet when it's in the grey part. If you want to test 50 concurrent requests the browser is probably a bad tool to use – apokryfos Jun 28 '19 at 08:19
  • @apokryfos Thak you,you are correct, ApacheBeam test is no problem. – Jinnrry Jun 28 '19 at 09:09

1 Answers1

3

This could be because of the sessions.

By default php store sessions in files and during request block this file, so next request can be started only after previous is finished.

Try to store sessions in memcache or database.

Alex
  • 127
  • 1
  • 3
  • This is a very good and probably barely appreciated point. A page making multiple concurrent ajax requests to load various portions can be significantly slowed down due to session locks. – Nick Jan 07 '21 at 14:18
  • This is an absolute brilliant answer, that have solved a problem I have had for literally several years! Using CakePHP and a file based session handler, PHP simply locked the session file thus creating a queue of waiting PHP requests if a PHP requests where running for a long time, for example caused by a long running database query. Simply using the database as the session handler completely solved the issue. Thank you very much! – StumpDK Mar 15 '23 at 21:58