[alibaba/tengine]limit_conn_zone指令不起作用

2024-06-26 848 views
8

为什么limit_conn_zone设置了不起作用?只能用limit_req_zone做限速吗? PS:两个模块都已经安装,现在需求是不要限速,要做限并发,貌似Tengine做不了啊,确定配置没有问题,nginx一次通过,Tengine就是死活不行,是不是ngx_http_limit_conn_module模块给改了,急急急.......

回答

3

cc @dengqian

2

ngx_http_limit_conn_module模块跟官方是一样的,没有改动,本地大文件测试了下是生效的。可以把配置和测试方法贴一下,看看中间是不是有什么问题。

5

Tengine之limit_conn_zone并发测试结果.docx

测试方法如下:
  1. Tengine:Tengine/2.2.2 (nginx/1.8.1)
  2. Nginx:nginx/1.7.4
  3. 测试工具:siege 4.0.4
    Tengine与Nginx进行相同配置如下:
    
    #http段:
    http {
    ……
    limit_conn_zone $binary_remote_addr zone=ip_limit:15m;
    ……
    }
server段:

server {

location / {
     limit_conn  ip_limit 10;
     limit_conn_status 500;
        root   /usr/local/webserver/nginx/html/web;
        index  index.php index.html index.htm;
    }

}

#### 测试Tengine:

siege -c 15 -r 1 www.zhang.com SIEGE 4.0.4 Preparing 15 concurrent users for battle. The server is now under siege... HTTP/1.1 200 0.02 secs: 555 bytes ==> GET / HTTP/1.1 200 0.02 secs: 555 bytes ==> GET / HTTP/1.1 200 0.02 secs: 555 bytes ==> GET / HTTP/1.1 200 0.02 secs: 555 bytes ==> GET / HTTP/1.1 200 0.02 secs: 555 bytes ==> GET / HTTP/1.1 200 0.02 secs: 555 bytes ==> GET / HTTP/1.1 200 0.02 secs: 555 bytes ==> GET / HTTP/1.1 200 0.02 secs: 555 bytes ==> GET / HTTP/1.1 200 0.03 secs: 555 bytes ==> GET / HTTP/1.1 200 0.03 secs: 555 bytes ==> GET / HTTP/1.1 200 0.03 secs: 555 bytes ==> GET / HTTP/1.1 200 0.03 secs: 555 bytes ==> GET / HTTP/1.1 200 0.03 secs: 555 bytes ==> GET / HTTP/1.1 200 0.03 secs: 555 bytes ==> GET / HTTP/1.1 200 0.03 secs: 555 bytes ==> GET /

Transactions: 15 hits Availability: 100.00 % Elapsed time: 0.03 secs Data transferred: 0.01 MB Response time: 0.02 secs Transaction rate: 500.00 trans/sec Throughput: 0.26 MB/sec Concurrency: 12.33 Successful transactions: 15 Failed transactions: 0 Longest transaction: 0.03 Shortest transaction: 0.02

测试结果: 15并发情况下全部通过,limit_conn ip_limit 10;没有起作用。


#### 测试Nginx:

siege -c 15 -r 1 www.zhang.com SIEGE 4.0.4 Preparing 15 concurrent users for battle. The server is now under siege... HTTP/1.1 200 0.07 secs: 33 bytes ==> GET / HTTP/1.1 200 0.07 secs: 33 bytes ==> GET / HTTP/1.1 500 0.07 secs: 186 bytes ==> GET / HTTP/1.1 500 0.07 secs: 186 bytes ==> GET / HTTP/1.1 500 0.07 secs: 186 bytes ==> GET / HTTP/1.1 500 0.07 secs: 186 bytes ==> GET / HTTP/1.1 200 0.08 secs: 33 bytes ==> GET / HTTP/1.1 200 0.08 secs: 33 bytes ==> GET / HTTP/1.1 200 0.08 secs: 33 bytes ==> GET / HTTP/1.1 200 0.08 secs: 33 bytes ==> GET / HTTP/1.1 200 0.08 secs: 33 bytes ==> GET / HTTP/1.1 200 0.08 secs: 33 bytes ==> GET / HTTP/1.1 200 0.09 secs: 33 bytes ==> GET / HTTP/1.1 200 0.09 secs: 33 bytes ==> GET / HTTP/1.1 200 0.09 secs: 33 bytes ==> GET /

Transactions: 11 hits Availability: 73.33 % Elapsed time: 0.09 secs Data transferred: 0.00 MB Response time: 0.11 secs Transaction rate: 122.22 trans/sec Throughput: 0.01 MB/sec Concurrency: 13.00 Successful transactions: 11 Failed transactions: 4 Longest transaction: 0.09 Shortest transaction: 0.07

测试结果: 15并发情况下,成功11个,拦截4个,并发数在往上加也是如此, limit_conn设置成功。