Nginx optimize the amount of concurrent access

Nginx by modifying the configuration file, linux kernel parameter optimization, to achieve high concurrency testing.

High concurrency test before using ab 1. Optimize

   [root@proxy ~]# ab -n 2000 -c 2000 http://192.168.4.5/

   Benchmarking 192.168.4.5 (be patient)

   socket : Too MANY Open Files ( 24- )          # prompt too many open files

2. Modify the Nginx configuration file, increase the amount of concurrency

   [root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf

   ...

   worker_processes 2 ; # consistent with the number of CPU cores

   events {

               worker_connections 65535 ; # each worker the maximum number of concurrent connections

             }

    ...

   [Proxy the root @ ~] # / usr / local / Nginx / sbin / Nginx  -s // load configuration reload

3. Optimize Linux kernel parameters (maximum number of files)

   [root @ Proxy ~] # ulimit -a                         // view all property values

   [root @ Proxy ~] # ulimit -Hn 100000                 // set a hard limit (temporary rule)

   [root @ Proxy ~] # ulimit -Sn 100000                 // Set the limit (temporary rule)

   [root@proxy ~]# vim /etc/security/limits.conf

   ...

   * Soft nofile   100000

   * Hard nofile  100000

   This profile points # 4, are as follows:

   # User or group requires a hard or soft limit limit limit value of the project

4. Optimize concurrency test server after, you will not be prompted to open a large number of files (because the client did not tune kernel parameters, so the proxy test)

   [root@proxy ~]# ab -n 2000 -c 2000 http://192.168.4.5/

End.

 

Guess you like

Origin www.cnblogs.com/liusingbon/p/11115488.html