In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "the current-limiting configuration process of nginx". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Limit_req zone=req_zone
The request is processed strictly according to the rate configured in limti_req_zone
If it exceeds the range of rate processing capacity, direct drop
It is shown that there is no delay for the requests received.
Limit_req zone=req_zone burst=5
Process the request according to the rate configured in limti_req_zone
At the same time, a buffer queue with a size of 5 is set up, and the requests in the buffer queue will be slowly processed.
Requests that exceed the burst buffer queue length and rate processing capacity are discarded directly
It shows that there is a delay in the request received.
Limit_req zone=req_zone burst=5 nodelay
Process the request according to the rate configured in limti_req_zone
At the same time, a buffer queue with a size of 5 is set up. When the request arrives, there will be a peak processing capacity, and the requests outside the peak processing number will be discarded directly.
After the peak request is completed, the buffer queue can no longer be put into the request. If rate=10r/s, and no requests come again during this period, the buffer queue can reply to one buffer request every 6 seconds until it is able to buffer 5 request locations.
Load_module modules/ngx_stream_module.so; # dynamic load module, must write the beginning
User nginx; # add a nginx user using useradd nginx
Worker_processes 4; # number of cpu cores * 2
Worker_rlimit_nofile 102400; # configure nginx to open the maximum number of files (one cpu,worker_cpu_affinity configuration per worker process)
Worker_cpu_affinity 0001 0010 0100 1000; # which cpu core is used by the worker process (take quad core as an example) 0001 is the first core of 4 cores 0010 is the second core of 4 cores
# error_log logs/error.log
# error_log logs/error.log notice
Error_log logs/error.log info
Pid logs/nginx.pid
Events {
Use epoll
Worker_connections 10240
}
Http {
Include mime.types
Default_type application/octet-stream
Log_format main'$remote_addr-$remote_user [$time_local] "$request"'
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent"$http_x_forwarded_for"'
# access_log logs/access.log main; # configure logs in the server virtual directory. Here is the global log.
Sendfile on
# tcp_nopush on
Turn off the output version number when server_tokens off; # error occurs
# keepalive_timeout 0
Keepalive_timeout 30
Gzip on; # compression consumes cpu
Gzip_buffers 4 16k
Gzip_comp_level 3; # Compression level
Gzip_disable "MSIE [1-6]"; # ie browsers 1-6 disable gzip
Gzip_min_length 1k
Gzip_http_version 1.0
Gzip_types text/plaion application/html application/css application/js; # File types that can be compressed
Gzip_vary on; # determines whether compression is supported according to the http header
Client_max_body_size 8m; # allows the client to upload a maximum file size by default
# current limit
# limit_conn_zone $binary_remote_addr zone=addr:10m; # concurrency limit (enable one at the same time)
Limit_req_zone $binary_remote_addr zone=qps:10m rate=1r/s; # request limit on processing one request per second
Limit_conn_log_level error
Limit_conn_status 503; # returns the status code when the limit is exceeded
Server {
# limit_conn addr 1; # concurrency limit is set to 1 to test that addr is in zone space at 53 lines (one is also enabled)
# limit_req zone=qps; # request limit
Limit_req zone=qps burset=1 nodelay; # request limit ()
}
# current-limiting end
}
This is the end of the content of "current-limiting configuration process of nginx". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.