Nginx Server prevents stress testing

Source: Internet
Author: User
Tags nginx server

Recently often help to do stress testing, with Webbech or AB and other tools to simulate the concurrent pressure server, if the server does not limit the number of connections or bandwidth, the server can easily be compressed across.
Cat nginx.conf
...
HTTP {
...
Limit_conn_zone $binary _remote_addr zone=one:10m;
#如果在1. After 1.8, the version also uses the syntax: Limit_zone name $variable size, warning Nginx: [Warn] the
"limit_zone" directive is deprecated, use the "Limit_conn_zone"
directive

#这里, set the client's IP address as the key. Note that the $BINARY_REMOTE_ADDR variable is used instead of the $remote_addr change
Amount The length of the $remote _addr variable is 7 bytes to 15 bytes, while the storage state occupies 32 bytes or 64 bytes in the 32-bit platform and 64 bytes in the 64-bit platform.
The length of the $BINARY_REMOTE_ADDR variable is fixed at 4 bytes, and the storage state occupies 32 bytes or 64 bytes in the 32-bit platform and 64 bytes in the 64-bit platform. A trillion
bytes of shared memory space can hold 32,000 32-bit states, 16,000 64-bit states. If the shared memory space is exhausted, the server will return 503 for all subsequent requests
(Service temporarily unavailable) error.

server {
Limit_conn one 10;
#指定一个会话最大的并发连接数 (used in conjunction with previous Limit_conn_zone), a separate directory can be limited, an IP can only initiate 10 connections, more than 10, return to the Services unavailable (503) status, The production environment should consider the office or LAN shared IP issues
Limit_rate_after 1m;
#设置单连接限速条件 (when the number of files bytes exceeds 1MB, the limit_rate speed limit is effective, speed limit 100k)
Limit_rate 100k;
#单连接限速
...
}
...
}

Nginx Server prevents stress testing

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.