Nginx server for some optimizations that easily break through 100,000 concurrent

Source: Internet
Author: User
Keywords servers Nginx concurrency
Tags cache configuration course example file files it is multiple

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.

Related Article

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.