In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Knowledge points of the article:
[] necessity of tuning
[] Dimensions and divergences of tuning
[] Nginx tuning item I. necessity of tuning
has been reluctant to write optimized content to share, really do not know how to write. Because, if you don't write well, you will be comforted by all kinds of condolences. I finally wrote it today, because there are too many people asking me in the group or giving up to share my experience.
Before talks about tuning, we need to know why tuning, the relationship between business operation and tuning.
Business operation: the online business runs normally and carries the company's business. Monitoring business: monitor the online business through the monitoring business and find problems in a timely manner. Optimize the business: through monitoring and analysis, find business problems or bottlenecks, and adjust and optimize the business or software in time. Test optimization: after the optimization is completed, the existing optimization needs to be tested to ensure that the business is stable and efficient in the current optimization mode, and can solve the current problems.
This is a process for business operation, and it is also the way for us to ensure that the business is stable, efficient and highly available.
Second, the dimensions of tuning and differences of opinion
The article on tuning is the most difficult to write, because I can only tell you the tuning options, but not the specific threshold, because different businesses run on different machines, the resources consumed are different; and because of different scenarios, the corresponding tuning items and thresholds are ever-changing, just like you and your brother in the upper bunk have caught a cold, but the medicine prescribed when you go to the hospital is completely different. It is precisely because of this that when many people see tuning articles and see specific tuning items or thresholds, two words will emerge. I am embarrassed to say, match it with a picture! It's good if everyone understands.
3. Nginx tuning nginx concurrency number nginx process optimizes nginx compression nginx local cache 1, nginx concurrency setting
Worker_processes 1
This is used to configure nginx to start several worker processes, which defaults to 1. Nginx also supports a configuration item called worker_cpu_affinity, that is, nginx can bind CPU for each worker process. I made the following configuration:
Events {worker_connections 1024;} 2, nginx bind the process to a fixed core
Worker_cpu_affinity 0010 0100 1000
Worker_processes 3 workerplate computers 0010 0100 1000 players # here 0010 0100 1000 is the mask, representing the 2nd, 3rd and 4th cpu cores respectively.
After restarting nginx, each of the three worker processes can use their own CPU.
Ps-eo psr,pid,arg view
Concurrency of nginx = worker_processes*worker_connections3, nginx compression function
Compression is too important for WEB servers, mainly in the following two directions:
1) improve the user experience: the transfer data is smaller and the user wait time is shorter.
2) saves the company bandwidth cost: after compression, the transmission data becomes smaller, and the bandwidth consumption is less.
Since it can give users a good experience, it can also save the company money. Why not do such a good thing, so this is a necessary artifact in the work.
However, to configure compression, you need to pay more attention to:
1) do not compress pictures, audio and video.
2) do not compress those less than 1K, otherwise the pressure will increase.
3) the higher the compression level, the more CPU is consumed
Compression is not turned on
Turn on compression
The code is as follows:
Gzip on
Gzip_http_version 1.1
Gzip_disable "MSIE [1-6]."
Gzip_proxied any
Gzip_min_length 1024
Gzip_buffers 4 8k
Gzip_comp_level 3
Gzip_types text/plain text/css application/x-javascript application/javascript application/xml
Gzip on; (enable gzip compression feature) gzip_http_version 1.1; its default value is HTTP/1.1, that is, gzip compression gzip_disable "MSIE [1-6]." is performed only for requests to HTTP/1.1 protocol; the setting is to disable IE1-6 version of gzip compression gzip_proxied any (this option is enabled when nginx is used as a front-end agent, which means that compression is unconditionally enabled no matter what information is returned by the headers header of the back-end server.) gzip_min_length 1024; (for pages with minimum compression, if the page is too small, it may become larger and larger. It is stipulated that compression is only enabled for pages greater than 1K.) gzip_buffers 48k (set up the system to get several units of cache to store the compressed result data stream of gzip and apply for 4 times the memory space according to the original data size of 8K.) gzip_comp_level 3 (compression level, 1 compression ratio minimum processing speed is the fastest, 9 compression ratio is the largest but slowest processing, but also the most consumption of CPU, generally set to 3) gzip_types text/plain text/css application/x-javascript application/javascript application/xml; (what type of page or document compression is enabled)
Turn on compression verification
4. Nginx local cache function
browser caching (Browser Caching) is designed to speed up browsing and save network resources. Browsers store recently requested documents on the user's disk.
There is an essential difference between client cache and compression. After the user downloads the data for the first time, it will be saved on the customer's local hard disk. Next time, as long as the local resource does not expire, it will be read directly from the local hard disk. The speed is the fastest, because you do not have to go to the WEB server to get the data. Similarly, it optimizes the user experience and saves the company's bandwidth costs.
It is important to note that:
caches generally cache images, website frames, audio and video, and other infrequent data. The best application is the Baidu home page, have you found that sometimes you can open the Baidu home page without the net, that is to look at your local cache.
Nginx local cache configuration directive
Nginx can set the Header of the browser through the expires instruction
Syntax: expires [time | epoch | max | off]
Default value: expires off
Scope: http, server, location
Use this directive to control the headers of "Expires" and "Cache-Control" in HTTP responses (to control the page cache). You can use positive or negative numbers in the time value. The value of the "Expires" header will be obtained by the current system time plus the time value you set. Epoch specifies that the value of "Expires" is 1 January, 1970, 00:00:01 GMT. Max specifies a value of 31 December 2037 23:59:59 GMT for "Expires" and 10 years for "Cache-Control". -1 specifies that the value of "Expires" is the current time of the server-1s, that is, it expires forever
Cache case
Location ~. *\. (jpg | png | jpeg) ${expires 30d;} js css cache for one hour location ~. *\. (js | css)? ${expires 1h;}
Cache verification
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.