Nging uses multi-core CPU to improve performance _ Configuration Parameter worker_cpu_affinity

Source: Internet
Author: User
Introduction nginx does not enable multi-core CPU by default. We can add worker_cpu_affinity configuration parameters to fully utilize the performance of multi-core CPU. CPU is the most critical resource for task processing and Computing. The more CPU cores, the better the performance. Rule setting (1) How many cores a CPU has, there are several digits, 1 indicates that the kernel is enabled, 0 indicates that the kernel is disabled (2) worker_processes can be enabled at most 8, the performance of more than eight processes will not be improved, and the stability will be reduced. Therefore, eight processes are enough to demonstrate the two-core CPU of the instance and start two processes.
worker_processes  2;worker_cpu_affinity 01 10;

01 indicates that the first CPU kernel is enabled, and 10 indicates that the second CPU kernel is enabled.

Worker_cpu_affinity 01 10; indicates that two processes are enabled. The first process corresponds to the first CPU kernel, and the second process corresponds to the second CPU core and two-core CPU, enabling eight processes.
worker_processes  8;worker_cpu_affinity 01 10 01 10 01 10 01 10;

Eight processes are enabled, which correspond to two kernels.

8-core CPU, enabling 8 Processes
worker_processes  8;worker_cpu_affinity 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001;

00000001 indicates that the first CPU kernel is enabled, 00000010 indicates that the second CPU kernel is enabled, and so on.

8-core CPU, enabling 2 processes
worker_processes  2;worker_cpu_affinity 10101010 01010101;

10101010 indicates that kernel 01010101, and are enabled. indicates that kernel, and are started.

Two processes correspond to eight kernels. After nginx configuration is restarted, The nginx service needs to be restarted.
/etc/init.d/nginx  restart

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.