V
V
Vlad Kravets2017-03-13 17:05:01
PHP
Vlad Kravets, 2017-03-13 17:05:01

Nginx + php7-fpm High load?

Hello ))
How can I set up a bunch of php7.0-fpm nginx for a load of 5000 requests per 1 second?
The maximum turns out to reach 1500, and then it does not always work ...
nginx.conf

user www-data;
worker_processes 8;
pid /run/nginx.pid;
worker_rlimit_nofile 300000;

events {
  worker_connections 10000;
   multi_accept on;
  use epoll;
}

http {

  ##
  # Basic Settings
  ##
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 30;
  client_max_body_size 10M;
  types_hash_max_size 2048;
  server_tokens off;
  reset_timedout_connection on;

  # server_names_hash_bucket_size 64;
  # server_name_in_redirect off;

  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  ##
  # SSL Settings
  ##

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;

  ##
  # Logging Settings
  ##

  access_log /var/log/nginx/access.log ;
  error_log /var/log/nginx/error.log;

  ##
  # Gzip Settings
  ##

  gzip off;
  gzip_disable "msie6";

  # gzip_vary on;
  # gzip_proxied any;
  # gzip_comp_level 6;
  # gzip_buffers 16 8k;
  # gzip_http_version 1.1;
  # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

  ##
  # Virtual Host Configs
  ##

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
}

virtual.conf
server {
  listen 80;
  listen [::]:80 ;

  server_name ;

   access_log  /var/log/nginx/gate.acces.log;
        error_log  /var/log/nginx/gate.error.log;


    root /var/www/*****/public;

    # Add index.php to the list if you are using PHP
    index index.html index.php index.htm index.nginx-debian.html;
    
    location / {

    if (!-d $request_filename){

            set $rule_0 1$rule_0;

    }

    if (!-f $request_filename){

    set $rule_0 2$rule_0;

    }

    if ($rule_0 = "21"){

    rewrite ^/ /index.php last;

    }
    }

        location ~ .php$ {
                try_files $uri =404;
                fastcgi_param ENVIRONMENT SANDBOX;
          fastcgi_pass 127.0.0.1:9000;
  #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        
  fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
 }
}

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry MiksIr, 2017-03-13
@miksir

5000 requests in 1 second for PHP script? Let's start with PHP, maybe not nginx. Count the response time of one request T, count the number of PHP workers N = 5000*T. Next, you launch this number of workers, make simultaneous requests to all workers, and by increasing the number of processor cores, you achieve the same server response time as it was on one worker. Well, this is without taking into account the fact that if a DBMS is used, its response time will also need to be corrected for a given competitiveness. There are not enough cores, we add servers.

F
Fixid, 2017-03-13
@Fixid

1. Never, or rather NEVER use if in NGINX, it's a very slow construct.
2. Go to unix:/run/php/php7.0-fpm.sock, immediately +10% to speed
3. Do a test on a static file, maybe you run into nginx

E
Elios, 2017-03-15
@strelov1

You can also take a look at https://github.com/php-pm/php-pm

X
xmoonlight, 2017-03-27
@xmoonlight

https://www.linode.com/docs/websites/nginx/configu...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question