Nginx speed limit,

Source: Internet
Author: User

Nginx speed limit,

Note:

The syntax for Versions later than nginx 1.1.8 is changed to limit_conn_zone $ binary_remote_addr zone = NAME: 10 m;

NAME is the NAME of the zone, please see here http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html

 

Maximum number of connections:

To restrict connections, you must first have a container that counts connections and add the following code to the http segment:

"Zone =" give it a name, which can be called at will. The name must be consistent with the following limit_conn.

$ Binary_remote_addr = uses binary to store the client address. 1 m can store 32000 concurrent sessions.

 

... Saving N characters

Http

{

Limit_conn_zone $ binary_remote_addr zone = addr: 10 m;

 

Next, we need to limit the speed of different locations (location segments) of the server. For example, to limit the number of concurrent connections of each IP address to 1

Server

{

Listen 80;

Server_name 192.168.11.128;

Index index.html index.htm index. php;

Limit_conn addr 1; # restrict each IP address to initiate only one connection (addr must correspond to the variable of limit_conn_zone)

Limit_rate 100 k; # The speed limit is KB/second.

Root html;

 

Note:

Limit_rate 100 k; // The speed limit is 100 k for each connection. Here is the connection speed limit, not the IP speed limit! If an IP address allows two concurrent connections, the IP address is limited to 2.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.