Make some general settings on the Nginx server to limit the number of concurrent and session space.
Nginx limit the number of IP concurrency, but also to limit the number of simultaneous connections to the same IP server
1, add Limit_zone
This variable can only be used on HTTP
code example:
Copy Code code as follows:
Vi/usr/local/nginx/conf/nginx.conf
Limit_zone one $remote _addr 10m;
2, add Limit_conn
This variable can be used in HTTP, server, location
Limit only one site, so add it to the server
Copy Code code as follows:
Vi/usr/local/nginx/conf/vhost/303i.com.conf
Limit_conn one 10;
3, restart Nginx
Copy Code code as follows:
Nginx Speed Limit Module
Reference:
About Limit_zone:http://wiki.nginx.org/nginxhttplimitzonemodule
About Limit_rate and Limit_conn:http://wiki.nginx.org/nginxhttpcoremodule
Nginx can speed up the directory by Httplimitzonemodule and httpcoremodule two components.
Copy Code code as follows:
HTTP {
Limit_zone one $binary _remote_addr 10m;
server {
location/download/{
Limit_conn one 1;
Limit_rate 300k;
}
}
}
Limit_zone is a container that defines a storage session state for each IP.
This example defines a 10m container that, according to 32bytes/session, can handle 320,000 sessions.
Copy Code code as follows:
Restrict each IP to initiate only one concurrent connection.
Copy Code code as follows:
Speed limit 300k for each connection.
Note that this is the speed limit for the connection, not the IP speed limit.
If an IP allows two concurrent connections, then this IP is the speed limit limit_ratex2.