Nginx Combat (four) speed limit function

Source: Internet
Author: User
Tags nginx server

If a lot of users, the same time download Nginx server above the resources, this will be the Nginx server I/O produced a great burden, so the nginx server download speed limit settings are necessary.

First configure a Limit_zone in the HTTP segment, and then use Limit_conn and limit_rate for the speed limit setting where needed, as a simple example.

HTTP {limit_zone one $binary _remote_addr 10m; server {location/files/{limit_conn one 1; limit_rate_after 1000k; limit _rate 100k; }}} Limit_zone, which defines a container for each IP that stores the session state. This example defines a 10m size container named one, which is used in the limit_conn. Limit_conn One 1, restrict each IP that is logged in a state to initiate only a single concurrent connection. Limit_rate_after 1000k, start the speed limit after downloading 1000k. Limit_rate 100k, speed limit 100k for each connection. Note that this is the speed limit for the connection, not the IP speed limit. If an IP allows three concurrent connections, then this IP is the speed limit for limit_ratex3, set the time to adjust according to their own needs, or will not achieve their desired purpose.

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.