Detailed Nginx configuration parameters

Source: Internet
Author: User
Tags epoll nginx server

Detailed configuration parameters user Nginx Nginx;
Nginx Users and Groups: User groups. Not specified under Window

worker_processes 8;
Worker process: number. Depending on the hardware, it is usually equal to the number of CPUs or twice times the CPU.

Error_log Logs/error.log;
error_log Logs/error.log Notice;
Error_log Logs/error.log Info;

Error log: Store path.


PID Logs/nginx.pid;
PID (process Identifier): Store the path.

Worker_rlimit_nofile 204800;
Specifies the maximum number of descriptors that a process can open.
This instruction refers to the maximum number of file descriptors opened by an nginx process, the theoretical value should be the number of open files (ulimit-n) and the number of nginx processes, but the Nginx allocation request is not so uniform, so it is best to be consistent with the value of ulimit-n.
Now the number of open files opened in the Linux 2.6 kernel is 65535,worker_rlimit_nofile 65535 should be filled accordingly.
This is because Nginx dispatch when the allocation request to the process is not so balanced, so if you fill 10240, total concurrency reached 340,000, there is a process may exceed 10240, this will return 502 error.


Events

{

Use epoll;

Use the epoll I/O model. Linux recommendation Epoll,freebsd is recommended to use Kqueue,window under unspecified.

Additional notes:

Similar to Apache, Nginx has different event models for different operating systems

A) Standard event model

Select, poll belongs to the standard event model, and if the current system does not have a more efficient method, Nginx chooses Select or poll

B) Efficient Event model

Kqueue: Used in FreeBSD 4.1+, OpenBSD 2.9+, NetBSD 2.0 and MacOS X. Using the kqueue with a dual-processor MacOS X system can cause the kernel to crash.

Epoll: Used in Linux kernel version 2.6 and later systems.

/dev/poll: Used for Solaris 7 11/99+,hp/ux 11.22+ (eventport), IRIX 6.5.15+ and Tru64 UNIX 5.1a+.

Eventport: Used for Solaris 10. To prevent kernel crashes, it is necessary to install security patches.

worker_connections 204800;

The maximum number of connections that do not have a worker process. According to the hardware adjustment, and the previous work process together with, as large as possible, but do not run the CPU to 100% on the line. The maximum number of connections allowed per process, in theory, for each nginx server. Worker_processes*worker_connections

keepalive_timeout;
KeepAlive time-out period.



Client_header_buffer_size 4k;
The buffer size of the client request header. This can be set according to your system paging size, generally a request header 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 with the command getconf PAGESIZE.
[Email protected] ~]# getconf PAGESIZE
4096
But there are also cases where client_header_buffer_size exceeds 4k, but client_header_buffer_size the value must be set to the integer multiple of system paging size.

open_file_cache max=65535 inactive=60s;

This will specify the cache for the open file, which is not enabled by default, max Specifies the number of caches, the recommended and the number of open files, and inactive refers to how long the file has not been requested to delete the cache.

open_file_cache_valid 80s;
This refers to how long it takes to check the cache for valid information.

open_file_cache_min_uses 1;
The minimum number of times the file is used in the inactive parameter time in the Open_file_cache directive, if this number is exceeded, the file descriptor is always opened in the cache, as in the previous example, if a file is not used once in inactive time, it will be removed.
}

Detailed Nginx configuration parameters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.