Enterprise-class web Nginx service Optimization (2)

Source: Internet
Author: User
Tags epoll

2.worker_cpu_affinity Parameter Official Description:

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8D/8B/wKioL1ihWd6ioeQ9AABfDWlMeQs730.jpg-wh_500x0-wm_ 3-wmp_4-s_3298564834.jpg "title=" 4cb93bf4-3263-4ca7-9986-92af2165acbe.jpg "alt=" Wkiol1ihwd6ioeq9aabfdwlmeqs730.jpg-wh_50 "/>

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8D/8D/wKiom1ihWfjTk6JPAABgw8BP9L8568.jpg-wh_500x0-wm_ 3-wmp_4-s_649743234.jpg "title=" 7c1732d9-5ea4-4756-b428-5e410f174822.jpg "alt=" Wkiom1ihwfjtk6jpaabgw8bp9l8568.jpg-wh_50 "/>

To view the CPU's number of cores: [[email protected] conf]# grep "physical"/proc/cpuinfophysical id:0address sizes:42 bits physical, bits Virtual

Top command very well remember summary

Enter top to view by.

3. Pressure test Configuration results:

A. Pre-configuration stress test results:

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8D/8D/wKiom1ihWiuBjjXwAABkx73XOOI658.jpg-wh_500x0-wm_ 3-wmp_4-s_2340517045.jpg "title=" 84bde739-3140-4551-ad70-43cf758eb421.jpg "alt=" Wkiom1ihwiubjjxwaabkx73xooi658.jpg-wh_50 "/>

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8D/8D/wKiom1ihWk_hs5BsAABmm4jXNxs081.jpg-wh_500x0-wm_ 3-wmp_4-s_3791902866.jpg "title=" 7bfd1605-12c2-4b62-a9d6-0e376cd0c26c.jpg "alt=" Wkiom1ihwk_ Hs5bsaabmm4jxnxs081.jpg-wh_50 "/>

By observing, we find that different CPU usage is relatively average before configuration.

B. After configuring worker_cpu_affinity:

[[email protected] conf]# grep worker_cpu nginx.conf worker_cpu_affinity 0001 0010 0100 1000;

The results of the stress test are as follows:

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8D/8D/wKiom1ihWoaAB_blAABaI9-eRMs232.jpg-wh_500x0-wm_ 3-wmp_4-s_2118692155.jpg "title=" 34725ec3-fe80-4533-9c97-fd48003504d5.jpg "alt=" wkiom1ihwoaab_ Blaabai9-erms232.jpg-wh_50 "/>

Through observation, we send the configuration after the different CPU usage is relatively average, and the test before the change is not big. So the default is more average, on the one hand, the software itself in the gradual optimization of the use of multi-core CPUs, on the other hand test data to be adjusted.

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8D/8B/wKioL1ihWqixaNLOAABvmCrOxHg203.jpg-wh_500x0-wm_ 3-wmp_4-s_2338900259.jpg "title=" 0ad7c894-62b7-436a-917c-3bc9cfd8c042.jpg "alt=" Wkiol1ihwqixanloaabvmcroxhg203.jpg-wh_50 "/>

  1. [[email protected]-01 conf]# man taskset

  2. TASKSET(1)                    Linux User'sManualTASKSET(1)

  3. NAME

  4.        taskset - retrieve or set a process’s CPU affinity

  5. SYNOPSIS

  6.        taskset [options] mask command [arg]...

  7.        taskset [options] -p [mask] pid


Other services can be used to make affinity for example: MySQL


650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8D/8B/wKioL1ihWtTSKnklAAAlSNgJIDs331.jpg-wh_500x0-wm_ 3-wmp_4-s_1882831217.jpg "title=" e571bc50-62ba-4459-9820-5f67389910d2.jpg "alt=" Wkiol1ihwttsknklaaalsngjids331.jpg-wh_50 "/>

Optimization of 1.1.5 Event processing model

Nginx connection processing mechanism lies in different operating systems using different IO models, in Linux using the Epoll IP multiplexing model, in FreeBSD using the Kqueue IO multiplexing model, in Solaris using the/dev/poll mode of IO multiplexing model , ICOP is used in Windows, and so on.

Choose different use[kqueue|rtsig|epoll|/dev/poll/select|poll depending on the system type]; This parameter is used in conjunction with the system, different systems use different parameters, we use Centos6.5, so we adjust to epoll model.

1. The specific configuration parameters are as follows:

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/8D/8D/wKiom1ihWvSzmZeJAABrm1CjaE0076.jpg-wh_500x0-wm_ 3-wmp_4-s_3596763715.jpg "title=" 9e3f69f3-fc96-4ce2-be69-4ecdfe4620b2.jpg "alt=" Wkiom1ihwvszmzejaabrm1cjae0076.jpg-wh_50 "/>

2. Official Note:

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8D/8B/wKioL1ihWxCgNaEsAAA1w7VUAH0164.jpg-wh_500x0-wm_ 3-wmp_4-s_1384577774.jpg "title=" 0947f0dc-dc6a-49ab-b857-319f77f5417f.jpg "alt=" Wkiol1ihwxcgnaesaaa1w7vuah0164.jpg-wh_50 "/>

  1. [ [email  protected] 01 conf ]# grep "Epoll" Nginx conf

  2.     use epoll;

1.1.6 Adjust the maximum number of connections allowed for a single process client

This value is based on the amount of memory used by the specific server performance program (the memory used by a process startup is determined by the program)

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8D/8B/wKioL1ihWzywc3aEAAByT92DMbs215.jpg-wh_500x0-wm_ 3-wmp_4-s_1102421377.jpg "title=" c1ce5a13-0447-4a70-a6de-97585af45964.jpg "alt=" Wkiol1ihwzywc3aeaabyt92dmbs215.jpg-wh_50 "/>

Worker_connections Official Note:

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8D/8D/wKiom1ihW1ngMQYUAACH6yWOyD4832.jpg-wh_500x0-wm_ 3-wmp_4-s_1542938990.jpg "title=" 78fd4a4d-a07a-4ac6-906f-9288c6618626.jpg "alt=" Wkiom1ihw1ngmqyuaach6ywoyd4832.jpg-wh_50 "/>

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8D/8B/wKioL1ihW3Swcw5NAAHxDscbnno100.jpg-wh_500x0-wm_ 3-wmp_4-s_1560567537.jpg "title=" 18ef03fc-69b3-4086-81cd-8dd65692aefa.jpg "alt=" Wkiol1ihw3swcw5naahxdscbnno100.jpg-wh_50 "/>

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8D/8B/wKioL1ihW43zbSRwAABryB6F4Bs025.png-wh_500x0-wm_ 3-wmp_4-s_1676340750.png "title=" 0ac1603b-6991-419a-9440-c60624ed7b16.png "alt=" Wkiol1ihw43zbsrwaabryb6f4bs025.png-wh_50 "/>

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8D/8B/wKioL1ihW6jAGLJGAAPhxBhdGDo456.png-wh_500x0-wm_ 3-wmp_4-s_3605269544.png "title=" Ee57fe74-e672-4c6b-832d-5d1fd9e0cbf5.png "alt=" Wkiol1ihw6jagljgaaphxbhdgdo456.png-wh_50 "/>

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8D/8B/wKioL1ihW7_zGLNCAAEiNJB3kok191.jpg-wh_500x0-wm_ 3-wmp_4-s_2369862085.jpg "title=" bdd9c4b1-2815-4a5c-982d-ead3c02e294c.jpg "alt=" wkiol1ihw7_ Zglncaaeinjb3kok191.jpg-wh_50 "/>

This is the number of client connections per worker process.

1.1.7 Configure the maximum number of file open per process:

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8D/8B/wKioL1ihW-zg0VQmAAAwpBKXKo4270.jpg-wh_500x0-wm_ 3-wmp_4-s_1515803701.jpg "title=" d2ff72cd-b245-48a4-9490-7b0d62fd7dfd.jpg "alt=" Wkiol1ihw-zg0vqmaaawpbkxko4270.jpg-wh_50 "/>

Worker_rlimit_nofilenumber Official description

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8D/8D/wKiom1ihXAryU-S9AAAxPMZhLuY343.jpg-wh_500x0-wm_ 3-wmp_4-s_1565439026.jpg "title=" d143e7d8-6294-49ab-bb44-36f750400f02.jpg "alt=" Wkiom1ihxaryu-s9aaaxpmzhluy343.jpg-wh_50 "/>

1.1.8 optimizing the hash table size of the server name:

650) this.width=650; "Src=" Https://s3.51cto.com/wyfs02/M00/8D/8B/wKioL1ihXCvRTo9oAAD9Su5JrDA228.jpg-wh_ 500x0-wm_3-wmp_4-s_727880777.jpg "title=" b580cc98-e390-4896-b3a1-6191b010eff5.jpg "alt=" Wkiol1ihxcvrto9oaad9su5jrda228.jpg-wh_50 "/>650) this.width=650;" Src= "https://s1.51cto.com/wyfs02/M01/8D/8B/ Wkiol1ihxfpyjtzlaabylkt3bek268.jpg-wh_500x0-wm_3-wmp_4-s_708947905.jpg "Title=" F13c6ac2-75cb-4538-af8b-2a64d2ee13d3.jpg "alt=" wkiol1ihxfpyjtzlaabylkt3bek268.jpg-wh_50 "/>650) this.width=650 ; "Src=" Https://s3.51cto.com/wyfs02/M02/8D/8B/wKioL1ihXGixTBm3AACgoBi_AWo468.jpg-wh_500x0-wm_3-wmp_4-s_ 3055384168.jpg "title=" 0cc4291a-a8cf-4b46-a2f3-f108185f9d14.jpg "alt=" wkiol1ihxgixtbm3aacgobi_awo468.jpg-wh_50 "/

In this case, you need to enlarge the setting value one more times:

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8D/8B/wKioL1ihXJGRCN71AAARLO4VS1s500.jpg-wh_500x0-wm_ 3-wmp_4-s_213001344.jpg "title=" 3969d068-a2ce-4cec-aff8-c327e2ae333d.jpg "alt=" Wkiol1ihxjgrcn71aaarlo4vs1s500.jpg-wh_50 "/>

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/8D/8D/wKiom1ihXKqwJiw6AACmhY0tuQ0956.jpg-wh_500x0-wm_ 3-wmp_4-s_294689865.jpg "title=" 54eada80-e4c1-4bab-acda-861b89ee211a.jpg "alt=" Wkiom1ihxkqwjiw6aacmhy0tuq0956.jpg-wh_50 "/>

Server_names_hash_max_size:

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8D/8E/wKiom1ihXOzAy3PaAABqwTQDQgc289.jpg-wh_500x0-wm_ 3-wmp_4-s_3773559599.jpg "title=" b9bac4b4-08a1-4895-855a-dce99d6c9b4e.jpg "alt=" Wkiom1ihxozay3paaabqwtqdqgc289.jpg-wh_50 "/>

1.1.19 Open Efficient File transfer mode

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8D/8E/wKiom1ihXQvBxe7EAABVgoWzqXI341.jpg-wh_500x0-wm_ 3-wmp_4-s_2522440553.jpg "title=" ad78bdc2-f764-47e7-a0f3-b172ba35e3e9.jpg "alt=" Wkiom1ihxqvbxe7eaabvgowzqxi341.jpg-wh_50 "/>

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8D/8B/wKioL1ihXSKwUCe-AACH_D_zvCk917.jpg-wh_500x0-wm_ 3-wmp_4-s_742929595.jpg "title=" b214fed7-0968-4505-956e-000f80b43c9f.jpg "alt=" Wkiol1ihxskwuce-aach_d_ Zvck917.jpg-wh_50 "/>


Enterprise-class web Nginx service Optimization (2)

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.