In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to optimize the performance of Nginx support SSL". In daily operation, I believe many people have doubts about how to optimize the performance of Nginx support SSL. Xiaobian consulted all kinds of information and sorted out simple and easy to use operation methods. I hope to answer your doubts about "how to optimize the performance of Nginx support SSL"! Next, please follow the small series to learn together!
initialization server
This web server runs in an ec2 t1.micro environment. I chose nginx + php5-fpm to run php pages, and for security reasons I used ssl.
test performance
I use blitz.io for stress and performance testing. Below are my stress test orders. The function is to add users gradually within 60 seconds. During the entire process,blitz.io creates one request per second and adds 4 users (rise/run = 260/60).
The copy code is as follows:
-p 1-250:60 https://mydomian.com
detailed explanation
For lovers, here is a detailed explanation. I will walk you through my thinking process in the following chapters.
If you edited the nginx configuration, restart the nginx server. If you edited the php5-fpm configuration, restart the service.
Try #1: Enhancing Hardware
My instinctive idea for improving performance is to enhance the server hardware and hope that everything will work. I upgraded my ec2 instance from t1.micro to c1.medium (optimized for high-traffic servers, not general purpose servers).
After that, I ran the blitz.io load test. Here's a screenshot of the results.
The peak performance of the server can reach 50 successful hits per second. As the load continues to increase, the number of timeouts rises and the number of hits falls.
Try #2: Evaluating CPU Performance
I re-executed the test while running htop in the background. I noticed that the utilization of both CPUs was no more than 13%. Memory used 300MB. It looks like the server is underutilized. So I made the following changes. The requested URL/etc/nginx/was not found on this server.
The copy code is as follows:
worker_processes 2;
Try #3, #4, #5: fine-tuning nginx + php5-fpm
In the following attempt, I changed the following values and still got the same result as attempt #1.
Try #3
The copy code is as follows:
/etc/ngnix/nginx.conf
worker_processes 2;
events {
worker_connections 19000;
multi_accept on;
}
...
_________
Try #4
The copy 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 trying the #4 change.
The copy 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 linode server. It has 1.5 GB of RAM and 8 CPUs. I copied all nginx and php5-fpm settings to this server.
Here's my command for stress testing using blitz.io.
The copy code is as follows:
-p 1-250:60 http://labs.mydomian2.com
This is the result:
Linode server is great! I was thinking,"is linode better than ec2? "。Before I decided to go down this path and migrate the code to linode, I wanted to make sure there was no difference between the two servers.
Try #7: The Big Revelation
I did a search and found nginx with some ssl related issues. The default nginx uses the dhe algorithm to create passwords (ciphers). Disabling this algorithm will improve performance.
So I edited/etc/nginx/nginx.conf to remove the kedh-cipher algorithm.
The copy 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 recreated the original stress test:
The copy code is as follows:
-p 1-250:60 https://mydomian.com
Here's the result:
It really works!!
Try #8: I really need hardware enhancements
Excellent, ec2 is very close to linode in performance. But do I really need a c1.medium instance to get this kind of performance? It may not be necessary... So I changed ec2 instance type back to t1.micro.
i Since micro instances only have one CPU, I reduced worker_processes in/etc/nginx/nginx.conf.
The copy code is as follows:
worker_processes 1;
...
Here's the result:
At this point, the study on "how to optimize the performance of Nginx to support SSL" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.