ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

limit_req_zone - неправильно огра ничивается скорость


  • To: nginx-ru@xxxxxxxxx
  • Subject: limit_req_zone - неправильно огра ничивается скорость
  • From: cronfy <cronfy@xxxxxxxxx>
  • Date: Sat, 25 Sep 2010 11:56:43 +0400
  • Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=IOfQt58g4oSkUWToSem+UP6+bOhyHdFddYtFdfGZXTc=; b=Auij0TwgGVbFJ31qEmrxrjdwH2IkhVfnphT85hOJTJD4qR6cS8dA675rTQfVpL0EBe MWv5kSjc8EcNRxcH2ecZ2EGvYfbGO6fxobC1sk7MYkyfjwDpK3CgGMS6LwruT0WAILFx RwyEpZeNVzaaneg6/QiVvP9GZyugJXlGc3IOU=
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; b=gnXhvGGD8SQthWKJlMjXmeTf5ZirfPFGrBbf6k1HPBPeY/OBpyz0iu9UFUNuDSbnPA 2n4TzTdnq4mbfoNz0po4gEbtxVvqqdZvW5bH4L+0zDe5dMLBIOPfpDpLoNpPSRoXb7/M ch72DpLj7QAkndHpzHG4MxyK3GZTt4zlT4w+M=

Здравствуйте.

Пытаюсь настроить ограничение запросов c IP в секунду с помощью
limit_req_zone, но почему-то реальная скорость запросов получается
гораздо ниже, чем указано в конфиге. Пример:

    limit_req_zone  $binary_remote_addr  zone=test_limit:30m   rate=5r/s;

    server {
        listen 127.0.0.1:80;
        server_name  testconn.loc;
        recursive_error_pages on;

        error_page 402 = @backend;
        location / {
                return 402;
        }

        location @backend {
            limit_req   zone=test_limit  burst=100;
            limit_req_log_level error;
            proxy_set_header   Host             $host;
            proxy_pass         http://127.0.0.1:31023$request_uri;
        }
    }

Тест 1.
Комментируем limit_req:
# ab -n 1000 http://testconn.loc/helloworld.php
Requests per second:    889.42 [#/sec] (mean)

Тест 2.
Возвращаем limit_req в @backend (сейчас rate=5r/s):
# ab -n 10 http://testconn.loc/helloworld.php
Requests per second:    2.01 [#/sec] (mean)

В error.log 5 записей:

2010/09/25 11:36:32 [warn] 63999#0: *75741 delaying request, excess:
0.990, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:36:33 [warn] 63999#0: *75765 delaying request, excess:
0.990, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:36:34 [warn] 63999#0: *75780 delaying request, excess:
0.990, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:36:35 [warn] 63999#0: *75792 delaying request, excess:
0.995, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:36:36 [warn] 63999#0: *75807 delaying request, excess:
0.995, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"


По идее уже неправильно: при 5r/s должен задерживать на 0.2, а
почему-то сразу выставляется 0.9

Тест 3.
Ставим rate=100r/s, количество запросов 50
# ab -n 50 http://testconn.loc/helloworld.php
Requests per second:    2.34 [#/sec] (mean)

Cитуация почти не меняется :(
в логе 25 записей вида

2010/09/25 11:41:53 [warn] 71858#0: *79943 delaying request, excess:
0.800, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:41:54 [warn] 71858#0: *79958 delaying request, excess:
0.700, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:41:55 [warn] 71858#0: *79979 delaying request, excess:
0.900, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:41:55 [warn] 71858#0: *80002 delaying request, excess:
0.800, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:41:56 [warn] 71858#0: *80023 delaying request, excess:
0.900, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"


Тест 4:
Ставим rate=500r/s
# ab -n 50 http://testconn.loc/helloworld.php
Requests per second:    4.73 [#/sec] (mean)

В логе 21 запись:

2010/09/25 11:44:31 [warn] 75535#0: *82655 delaying request, excess:
0.500, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:44:31 [warn] 75535#0: *82665 delaying request, excess:
0.500, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:44:32 [warn] 75535#0: *82676 delaying request, excess:
0.500, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"

Тест 5:
Ставим rate=1000r/s, увеличиваем количество запросов до 200
# ab -n 200 http://testconn.loc/helloworld.php
Requests per second:    88.61 [#/sec] (mean)

В логе 2 записи:
2010/09/25 11:50:50 [warn] 83559#0: *2038 delaying request, excess:
1.000, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"
2010/09/25 11:50:51 [warn] 83559#0: *2141 delaying request, excess:
1.000, by zone "test_limit", client: 127.0.0.1, server: testconn.loc,
request: "GET /helloworld.php HTTP/1.0", host: "testconn.loc"



С чем может быть связано такое поведение? Заметил проблему на
nginx/0.8.50, тестировал на nginx/0.8.34. FreeBSD 7.3.


-- 
// cronfy

_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://nginx.org/mailman/listinfo/nginx-ru


 




Copyright © Lexa Software, 1996-2009.