about limit_req module's implement.

Maxim Dounin mdounin at mdounin.ru
Thu Feb 24 22:46:54 MSK 2011


Hello!

On Thu, Feb 24, 2011 at 10:26:50PM +0800, Simon Liu wrote:

> Thanks!
> 
> this blew code is in  limit_req module:
> 
> static ngx_int_t
> ngx_http_limit_req_lookup(ngx_http_limit_req_conf_t *lrcf, ngx_uint_t hash,
>     u_char *data, size_t len, ngx_uint_t *ep)
> {
> ..................................................................
>                 tp = ngx_timeofday();
> 
>                 now = (ngx_msec_t) (tp->sec * 1000 + tp->msec);
>                 ms = (ngx_msec_int_t) (now - lr->last);
> 
>                 excess = lr->excess - ctx->rate * ngx_abs(ms) / 1000 + 1000;
> 
>                 if (excess < 0) {
>                     excess = 0;
>                 }
> 
>                 *ep = excess;
> 
>                 if ((ngx_uint_t) excess > lrcf->burst) {
>                     return NGX_BUSY;
>                 }
> ...............................................
> }
> 
> in this code ,  while  two or more request in one milliseconds , excess will
> be greater than 0,   in addition burst is 0 in default , therefore
> ngx_http_limit_req_lookup
> will return NGX_BUSY, nginx will send 503 to client.  but  this situation is
> not send 503 to client. this is limit_req's bug?

ENOPARSE

It is not clear what you are complaining about.

Strictly speaking, with burst=0 no requests should be allowed at 
all.  Though it makes a little sense and nginx allows one request 
and rejects everything else with 503 until 1/rate seconds passes.

Maxim Dounin



More information about the nginx-devel mailing list