In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how nginx limits the number of concurrent connection requests. Xiaobian thinks it is quite practical, so share it with you for a reference. I hope you can gain something after reading this article.
Limit the number of concurrent connections
Example Configuration:
http { limit_conn_zone $binary_remote_addr zone=addr:10m; #limit_conn_zone $server_name zone=perserver:10m; server { limit_conn addr 1; limit_conn_log_level warn; limit_conn_status 503; }}
limit_conn_zone key zone=name:size; Defines the configuration of concurrent connections
A definable module is an http module.
The key keyword is used to limit the number of connections according to what variables, such as binary_remote_addr and $server_name, according to actual business requirements.
zone defines the configuration name and maximum shared memory. If the memory occupied exceeds the maximum shared memory, the server returns an error.
$binary_remote_addr in the example is a binary user address, which is used to save bytes and reduce the size of shared memory.
limit_conn zone number; concurrent connection limit
definable modules are http, server, location modules
zone specifies which limit_conn_zone configuration to use for
number is the limit number of connections, which is limited to 1 connection in the example configuration.
limit_conn_log_level info | notice | warn |error ; log level at which the restriction occurred
definable modules are http, server, location modules
limit_conn_status code; Error code returned when limit occurs, default 503
Defined modules are http, server, location module
Limit concurrent requests
limit_req_zone key zone=name:size rate=rate; Defines the configuration to limit concurrent requests.
If the memory occupied exceeds the maximum shared memory, the server returns an error response.
rate defines the request rate, e.g. 10r/s 10 requests per second 10r/m 10 requests per minute
limit_req zone=name [burst=number] [nodelay | delay=number];
zone defines which limit_req_zone configuration to use
burst=number sets the number of requests that can be stored in the bucket, which is the buffer size of the request
The request of the nodelay burst bucket is no longer buffered, and is delivered directly. The rate request rate is invalid.
delay=number The first time a request is received, number of requests can be delivered in advance.
definable modules are http, server, location modules
limit_req_log_level info | notice | warn |error; log level at which the restriction occurred
definable modules are http, server, location modules
limit_req_status code; Error code when limit occurs
definable modules are http, server, location modules
Example Configuration 1
http { limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; limit_req zone=one burst=5;}
The request rate is 1 request per second. Burst bucket size can hold 5 requests. Requests that exceed the limit return an error.
Example Configuration 2
http { limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; limit_req zone=one burst=5 nodelay;}
Example Configuration 2 adds the nodelay option to Example Configuration 1. Then the rate request rate doesn't work. All requests in the burst bucket are passed directly. Requests that exceed the limit return an error.
Example Configuration 3
http { limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; limit_req zone=one burst=5 delay=3;}
Example Configuration 3 adds the delay=3 option to Example Configuration 1. Indicates that the first 3 requests are delivered immediately, and then the rest are delivered at the request rate. Requests that exceed the limit return an error.
About "nginx how to limit the number of concurrent connection requests" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.
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.