nginx limit_conn_zone не работает на моем сервере - PullRequest
0 голосов

Я пытаюсь применить limit_conn к моему серверу для тестирования, но он не работает.

Мой nginx .conf

events {}

http {

    include mime.types;

    limit_conn_zone $binary_remote_addr zone=addr:10m;

    server {
       listen 80;

       location /downloads/ {
           limit_conn addr 1;

           return 200 "Hello";
       }

    }
}

Затем я запускаю Apache Бенчмарк

ab -n 10 -c 10 http://MY_IP_ADDRESS_OF_SERVER/downloads/

Я получаю эти выходные данные:

This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking MY_IP_ADDRESS_OF_SERVER (be patient).....done


Server Software:        nginx/1.16.1
Server Hostname:        MY_IP_ADDRESS_OF_SERVER
Server Port:            80

Document Path:          /downloads/
Document Length:        16 bytes

Concurrency Level:      10
Time taken for tests:   0.004 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      1760 bytes
HTML transferred:       160 bytes
Requests per second:    2693.97 [#/sec] (mean)
Time per request:       3.712 [ms] (mean)
Time per request:       0.371 [ms] (mean, across all concurrent requests)
Transfer rate:          463.03 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    2   0.3      2       2
Processing:     0    1   0.6      1       2
Waiting:        0    1   0.5      1       2
Total:          2    3   0.3      3       3

Percentage of the requests served within a certain time (ms)
  50%      3
  66%      3
  75%      3
  80%      3
  90%      3
  95%      3
  98%      3
  99%      3
 100%      3 (longest request)

Но я ожидаю получить в выводе что-то вроде этого

Complete requests:      10
Failed requests:        1
Non-2xx responses:      9

Кажется, что limit_conn не ' не работает на моем сервере. Почему это не работает и как я могу решить эту проблему?

...