In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the knowledge of how to optimize small vps in nginx, the content is detailed and easy to understand, the operation is simple and fast, and it has certain reference value. I believe everyone will gain something after reading this article. Let's take a look at it together.
Small vps are limited by system resources, and when the number of visits is too large, exceeding the limit that the system can withstand, some requests will be 502. In the case of sufficient system resources, optimize nginx,php-fpm, and the system itself to achieve two goals:
1. Rational allocation of system resources to maximize the use of limited resources. Good steel goes to the blade.
Minimize disk i/o
1. Main resources of the system
[root@xxxxxx nginx]# free -m total used free shared buffers cached mem: 994 815 179 0 43 118 -/+ buffers/cache: 453 540 swap: 0 0 0 [root@xxxxxx nginx]# cat /proc/cpuinfo processor : 0 vendor_id : genuineintel cpu family : 6 model : 62 model name : intel(r) xeon(r) cpu e5-2650 v2 @ 2.60ghz stepping : 4 cpu mhz : 2594.024 cache size : 20480 kb physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic 。。。。Omit... bogomips : 5188.04 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management:
II. Php-FPM optimization
pm = dynamic //Number of processes, dynamically allocated pm.max_children = 24 //maximum number of processes pm.start_servers = 8 //Number of processes at startup pm.min_spare_servers = 8 //Minimum number of idle processes pm.max_spare_servers = 24 //Maximum number of processes when the server is idle php_flag[display_errors] = off //After running for a while, turn off the error message
php-fpm A process accounts for between 20m-30m, top Look at the percentage of memory occupied by php-fpm, estimate it to know. max_children, max_spare_servers Not bigger is better.
Third, nginx optimization
1. Install the latest stable version
# vim /etc/yum.repos.d/nginx.repo //plus [nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1# yum install nginx //update nginx
2, Optimize configuration nginx
worker_processes auto; //set auto, nginx process dynamic allocation # access_log //comment out, reduce i/o# log_format //comment out, reduce i/ogzip on; //open gzipgzip_min_length 1k;gzip_buffers 4 16k;gzip_http_version 1.1;gzip_comp_level 5; //1-9, the bigger the compression, the better, the more resources consumed gzip_types text/plain application/x-javascript text/css application/xml;gzip_vary on;
For small vps, worker_processes can be set to 1 or 2. That's enough.
For small vps, the above nginx,php-fpm optimizations are beneficial.
4. Linux startup process optimization
The copy code is as follows:
# chkconfig --list |grep on
Check for boot-up processes and turn off unnecessary boot-ups. If you encounter something you don't know, it's best to check it first before deciding whether to close it.
About "how to optimize small vps in nginx" The content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of the knowledge of "how to optimize small and medium-sized vps in nginx." If you still want to learn more knowledge, you are welcome to pay attention to the industry information channel.
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.