Configure Nginx multicore cpu,worker_cpu_affinity usage and example affinity DS2 2 affinity Affinity

Source: Internet
Author: User
Nginx does not turn on using multicore CPUs by default, we can make full use of multicore CPUs by adding worker_cpu_affinity configuration parameters. CPU is the task processing, compute the most critical resources, the more CPU cores, the better performance.
configuring Nginx Multi-core cpu,worker_cpu_affinity usage methods and examples
1.2-core CPU, open 2 processes
worker_processes 2;
worker_cpu_affinity;
01 means the first CPU core is enabled, and 10 means that a second CPU core is enabled
worker_cpu_affinity 01 10; Indicates that two processes are turned on, the first process corresponds to the first CPU core, and the second process corresponds to the second CPU core.
2.2-core CPU, open 4 processes
worker_processes 4;
worker_cpu_affinity -Ten;
four processes are turned on, each of which corresponds to opening 2 CPU cores
3.4 Core CPU, open 4 processes
worker_processes 4;
worker_cpu_affinity 0001 0010 0100;
0001 means the first CPU core is enabled, 0010 means that the second CPU core is enabled, and so on
4.4-Core CPU, open 2 processes
worker_processes 2;
worker_cpu_affinity 0101 1010;
0101 means to open the first and third cores, 1010 to open the second and fourth cores
2 processes corresponding to four cores
The worker_cpu_affinity configuration is written in the/etc/nginx/nginx.conf.
The 2 core is 01, the Quad core is the 0001,8 core is 00000001, the number of cores, there are several numbers, 1 means that the kernel is turned on, and 0 indicates that the kernel is closed.
5.8 Core CPU, open 8 processes
worker_processes 8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
0001 means the first CPU core is enabled, 0010 means that the second CPU core is enabled, and so on
With up to 8 worker_processes, more than 8 performance increases are no longer raised and stability becomes lower, so 8 processes are sufficient.
after the configuration is complete, restart Nginx, perform/etc/init.d/nginx restart
tests if Nginx is useful to multiple CPU cores and executes AB.EXE-C 1000-n on another machine http://www.domain.com/index.php
Ab.exe is a performance testing tool with Apache back-up that simulates concurrent requests from multiple clients.
perform top on the server and press 1 to see how the CPU core works. If the utilization of multiple CPU cores is not much different, it proves that Nginx has successfully utilized multi-core CPU.

At the end of the test, the load on the CPU core should be reduced at the same time.

Http://blog.chinaunix.net/uid-20662363-id-2953741.html

The above describes the configuration Nginx multi-core cpu,worker_cpu_affinity usage and examples, including the affinity aspects of the content, I hope that the PHP tutorial interested in a friend to help.

  • 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.