Optimizations in Nginx directives (configuration files)
Worker_processes 8;
Nginx number of processes, it is recommended to be specified according to the number of CPUs, generally a multiple of it.
Worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
Allocate CPUs for each process, in the example above, 8 processes are allocated to 8 CPUs, of course you can write multiple, or a process is assigned to multiple CPUs.
Worker_rlimit_nofile http://www.aliyun.com/zixun/aggregation/12560.html ">102400;
This instruction is when a nginx process opens the maximum number of file descriptors, the theoretical value should be the maximum number of open files (ulimit-n) and the number of nginx process, but the Nginx allocation request is not so uniform, so it is best to be consistent with the value of ulimit-n.
Use Epoll;
Using the Epoll I/O model, needless to say.
Worker_connections 102400;
The maximum number of connections allowed per process, in theory, the max number of connections per Nginx server is worker_processes*worker_connections.
Keepalive_timeout 60;
KeepAlive timeout time.
Client_header_buffer_size 4k;
Client requests the size of the head buffer, this can be based on your system paging size to set, the general one requested head size will not exceed 1k, but because the general system paging is greater than 1k, so this is set to paging size. The paging size can be obtained using the command getconf pagesize.
Open_file_cache max=102400 inactive=20s;
This will specify caching for open files, which are not enabled by default, max Specifies the number of caches, and the recommended number of files is the same, inactive refers to how long the file has not been requested to delete the cache.
Open_file_cache_valid 30s;
This refers to how long it is to check the cache for valid information.
Open_file_cache_min_uses 1;
The minimum number of times a file is used in a inactive parameter in the open_file_cache instruction, and if this number is exceeded, the file descriptor is always open in the cache, as in the example above, if a file is not used once in inactive time, it will be removed.