Race condition in limit_zone/limit_conn?
Maxim Dounin
mdounin at mdounin.ru
Tue May 4 03:58:39 MSD 2010
Hello!
On Mon, May 03, 2010 at 03:37:49PM -0400, Barry Jaspan wrote:
[...]
> ab -n 4 -c 4 'http://test3.bjaspan.acquia-sites.com/sleep.php?sleep=30'
>
> what I would expect to see is that 3 connections would succeed and the
> fourth would fail quickly with a 503. Instead, what happens is that
> all 4 fail immediately with a 503.
>
> The log is not particularly illuminating (at least to me):
>
> root at bal-11:~# tail -f /var/log/nginx/error.log | grep "limit"
> 2010/05/03 19:29:34 [debug] 4080#0: *1 limit zone: 265A3FCB 1
> 2010/05/03 19:29:34 [debug] 4080#0: *2 limit zone: 265A3FCB 2
> 2010/05/03 19:29:34 [debug] 4080#0: *4 limit zone: 265A3FCB 3
> 2010/05/03 19:29:34 [error] 4080#0: *6 limiting connections by zone
> "max_conn", client: 127.0.0.1, server: domain.name, request: "GET
> /sleep.php?sleep=15 HTTP/1.0", host: "domain.name"
> 2010/05/03 19:29:34 [debug] 4080#0: *6 http write filter limit 0
> 2010/05/03 19:29:34 [error] 4080#0: *8 limiting connections by zone
> "max_conn", client: 127.0.0.1, server: domain.name, request: "GET
> /sleep.php?sleep=15 HTTP/1.0", host: "domain.name"
> 2010/05/03 19:29:34 [debug] 4080#0: *8 http write filter limit 0
> 2010/05/03 19:29:35 [error] 4080#0: *9 limiting connections by zone
> "max_conn", client: 127.0.0.1, server: domain.name, request: "GET
> /sleep.php?sleep=15 HTTP/1.0", host: "domain.name"
> 2010/05/03 19:29:35 [debug] 4080#0: *9 http write filter limit 0
> 2010/05/03 19:29:35 [error] 4080#0: *10 limiting connections by zone
> "max_conn", client: 127.0.0.1, server: domain.name, request: "GET
> /sleep.php?sleep=15 HTTP/1.0", host: "domain.name"
> 2010/05/03 19:29:35 [debug] 4080#0: *10 http write filter limit 0
> 2010/05/03 19:29:35 [debug] 4080#0: limit zone cleanup: 265A3FCB 3
> 2010/05/03 19:29:35 [debug] 4080#0: limit zone cleanup: 265A3FCB 2
> 2010/05/03 19:29:35 [debug] 4080#0: limit zone cleanup: 265A3FCB 1
You had at least 7 connections (*1, *2, *4, *6, *8, *9, *10)
during the test. First 3 were passed through, others were
rejected.
Most likely you configured nginx to proxy to itself and this
causes extra connections.
Maxim Dounin
More information about the nginx
mailing list