原帖由 gdtv 于 2009-11-14 14:51 发表 
现在还没解决
1、如果用limit_conn,那么多余的图片会显示X,而不是排列等待下载
2、如果用limit_rate,那么空闲的时候limit_rate不能自动调整,浪费
现在只有寄望于if($slow){set $limit_rate 4k;},可是不知这个怎么弄。 ...
limit_conn 是限制并发数的 就像是IIS的连接限制一样 超过了限制就是返回503之类
limit_rate 具体你可以看http://wiki.nginx.org/NginxHttpCoreModule然后查询 limit_rate 我贴一边
limit_rate
syntax: limit_rate speed
default: no
context: http, server, location, if in location
Directive assigns the speed of transmission of the answer to client. Speed is assigned in the bytes per second. Limitation works only for one connection, i.e., if client opens 2 connections, then total velocity will be 2 times higher then the limit set.
If it is necessary to limit speed for the part of the clients at the server level, based on some kind of condition - then this directive does not apply. Instead you should specify the limit by assigning the value to the $limit_rate variable, as shown below:- server {
- if ($slow) {
- set $limit_rate 4k;
- }
- }
复制代码 limit_rate_after
syntax: limit_rate_after time
default: limit_rate_after 1m
context: http, server, location, if in location
The directive limits speed only after the first part was sent.- limit_rate_after 1m;
- limit_rate 100k;
复制代码
不过我以前对以下载试过 在location中limit_rate无效(内网测试)
server {
if ($slow) {
set $limit_rate 4k;
}
} 这个我没试验过 呵呵 |