current position:Home>How to optimize the performance of nginx supporting SSL
How to optimize the performance of nginx supporting SSL
2022-04-29 19:27:10【Billion cloud speed】
What's wrong Nginx Support SSL To optimize the performance of
This article mainly introduces “ What's wrong Nginx Support SSL To optimize the performance of ”, In daily operation , I believe a lot of people are talking about Nginx Support SSL There are doubts about optimizing the performance of , Xiao Bian consulted all kinds of materials , Sort out simple and easy-to-use operation methods , I hope to answer ” What's wrong Nginx Support SSL To optimize the performance of ” Your doubts help ! Next , Please follow Xiaobian to learn !
initialization The server
This web The server runs on a ec2 t1.micro Environmental Science . I choose nginx + php5-fpm To run the php page , For safety reasons, I use ssl.
Test performance
I use blitz.io To conduct pressure and performance tests . Here are my stress test commands . The function is to 60 Gradually increase users in seconds . In the whole process ,blitz.io Create one request per second and add 4 Users (rise/run = 260/60).
Copy code The code is as follows :
-p 1-250:60 https://mydomian.com
Detailed explanation
For fans , Here is a detailed explanation . I will lead you through my thinking process in the following chapters .
If you edit nginx To configure , So restart nginx The server . If you edit php5-fpm To configure , Then restart the service .
Try #1: Enhanced hardware
For improving performance , My instinct is to enhance the server hardware , I hope everything will work properly . I will ec2 Instance from t1.micro Upgrade to c1.medium( Optimized for high traffic servers , Not a general-purpose server ).
After that , I ran blitz.io The load test . This is a screenshot of the result
The peak performance of the server can reach... Per second 50 A successful hit . As the load continues to increase , The number of timeouts increased , And the number of hits decreased .
Try #2: Effect evaluation cpu performance
I rerun the test , Running in the background at the same time htop. I noticed two cpu The utilization rate of does not exceed 13%. Memory used 300mb. It seems that the server is not fully utilized . So I made the following changes . I edited it /etc/ngnix/nginx.conf
Copy code The code is as follows :
worker_processes 2;
Try #3, #4, #5: fine-tuning nginx + php5-fpm
In the following attempts , I changed the following values , Still get and try #1 The same result .
Try #3
Copy code The code is as follows :
/etc/ngnix/nginx.conf
worker_processes 2;
events {
worker_connections 19000;
multi_accept on;
}
...
_________
Try #4
Copy code The code is as follows :
/etc/ngnix/nginx.conf
worker_processes 2;
events {
worker_connections 19000;
multi_accept on;
}
http {
gzip on;
gzip_disable "msie6";
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml application/javascript text/css application/x-javascript;
…
}
...
________
Try #5
I didn't cancel the attempt #4 Changes
Copy code The code is as follows :
/etc/php5/fpm/pool.d/www.conf
pm.max_children = 160
pm.start_servers = 24
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 1500
Try #6: Deploy another server
I have another one linode The server . have 1.5gb Memory and 8 individual cpu. I copy all nginx and php5-fpm To this server .
This is what I use blitz.io The order to do the stress test
Copy code The code is as follows :
-p 1-250:60 http://labs.mydomian2.com
This is the result :
linode The server is great ! I was thinking “linode Than ec2 Good yao ?”. After I decided to follow this line of thought , Migrate the code to linode Before , I want to make sure there is no difference between the two servers .
Try #7: Great enlightenment
I searched for , Find out nginx There are some ssl Related issues . Default nginx Use dhe Algorithm to create password (cipher). Disabling this algorithm will improve performance .
All I edit /etc/nginx/nginx.conf Removed kedh cryptographic algorithm .
Copy code The code is as follows :
worker_processes 2;
events {
worker_connections 1024;
}
http {
gzip on;
gzip_disable "msie6";
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml application/javascript text/css application/x-javascript;
ssl_ciphers all:!kedh!adh:rc4+rsa:+high:+medium:+low:+sslv2:+exp;
…
}
...
I repeated the original stress test :
Copy code The code is as follows :
-p 1-250:60 https://mydomian.com
This is the result :
It really works !!!!
Try #8: I really need to enhance the hardware
fantastic ,ec2 And linode Very close in performance . But I really need c1.medium Examples to achieve this performance ? It may not be necessary ... So I will ec2 The instance type of is changed back to t1.micro.
i because micro There is only one instance cpu, All I am /etc/nginx/nginx.conf There's less worker_processes.
Copy code The code is as follows :
worker_processes 1;
...
This is the result :
Here we are , About “ What's wrong Nginx Support SSL To optimize the performance of ” That's the end of my study , I hope we can solve your doubts . The combination of theory and practice can better help you learn , Let's try ! If you want to continue to learn more related knowledge , Please continue to pay attention to Yisu cloud website , Xiaobian will continue to strive to bring you more practical articles !
copyright notice
author[Billion cloud speed],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291744570664.html
The sidebar is recommended
- How to use HTML to display segmentation
- How to define and use HTML box model
- How to use the box pack attribute and box align attribute inside the box in HTML
- What are the differences and relationships among HTML, CSS and JS
- How to save home page as HTML
- How to solve the post request return 405 of nginx reverse proxy to HTML page
- How to upload pictures without refresh with HTML5 + PHP
- How to define HTML text tags, pictures, paths, hyperlinks and anchors
- How to upload static HTML files to the host or server
- How to use calculated and watch in Vue
guess what you like
How does Vue Preview PDF, word, xls, PPT and txt files
Can jQuery listen for events
Luxury cars "senseless price increase", the configuration of the new Porsche Macan remains unchanged, with a maximum increase of 19000 yuan
1-ch579m program upgrade OTA (self built Internet of things platform) - ch579m uses its own Ethernet to remotely download and upgrade MCU program through HTTP (MCU program rotation check and update)
The front-end downloads files, and the back-end sends gzip files. Is there a way to get the file size?
Why does Vue route jump refresh the page?
The conversion code of Babel in the project needs to include node_ Modules
[nginx] prefix removal in nginx proxy pass configuration
Vue packaging error module build failed: typeerror: this getOptions is not a function
Use of I18N in Vue
Random recommended
- Who is bunk, the new hero of endless dungeon? Introduction to new hero bunk skills
- Front end entry first bullet | development tools and configuration
- Nice HTML login page
- Vue error prone summary
- Summary of material resources website (icon | wallpaper | Adobe plug-in | jQuery plug-in | badge | online conversion | color splicing | continuous update)
- Step by step, configure nodesjs environment with hbuilder for Vue JS development
- Vue sets the global websocket and accepts message notification processing on the corresponding page
- Solve the problem that vuex data is reset during page refresh
- Java data structures and algorithms lesson 2 - generics
- Leetcode-82 - delete duplicate Element II in the sorting linked list
- [front end] quickly create HTML
- Vue router routing navigation
- Vue router redirection and alias
- Vue router named routes, (nested) named views
- Dynamic components & slots & custom instructions for getting started with Vue Foundation
- JavaScript algorithm -- heap sorting
- K8s deployment-43-take you to learn ingress nginx (Part 2)
- Detailed breakdown of actual combat of CMS background system project (VII)
- Explore the store | new architecture blessing, performance and safety. This style is super personality_ Integra_ Honda_ platform
- Sports kit blessing / replacement of four cylinder engine Chevrolet chuangku RS live shooting analysis_ Aspect_ Display screen_ Complete vehicle
- Talking about nodejs server
- Node. js< I & gt—— Encounter node and repl usage
- Vue basic API: calculation attribute + filter + listener
- 1-stm32 + mn316 (nb-iot) remote upgrade OTA (self built Internet of things platform) - STM32 uses HTTP to download program files and upgrade programs through mn316 (MCU program rotation check and update)
- Vue Axios response interception
- vue3 ref
- How does Vue transfer the data from the parent component to the child component intact?
- The back-end interface developed by springboot in idea and the Vue front-end developed by vscode. How to integrate Vue code into springboot?
- Fried cold rice series 4: scope and closure in JavaScript
- Typescript type compatibility learning
- Summary of bugs encountered in front-end development
- Chrome developer tool: performance analysis using web panel
- Collation of common semantic elements and global attributes in HTML
- Life cycle in Vue
- 5.1 fear of traffic jam? With a budget of less than 100000, these cars with adaptive cruise make it easy for you to travel
- Docker compose deploy nginx configure SSL
- The content of element type “mapper“ must match “(cache-ref|cache|resultMap*|parameterMap*|sql*|inse
- -CSS-
- Vue uses two-way binding to implement the user registration page
- Is Infiniti qx60 worth less than 400000 yuan? It depends on the discount