about limit_req module's implement.
Simon Liu
simohayha.bobo at gmail.com
Fri Feb 25 04:22:50 MSK 2011
Thanks!
my question is , when client send two or more request in one milliseconds,
whatever you set rate is , the nginx will send 503 to client.because nginx
limit_req's precision is milliseconds.
On Fri, Feb 25, 2011 at 3:46 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> 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
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://nginx.org/mailman/listinfo/nginx-devel
>
--
博观约取
豆瓣:www.douban.com/people/mustang/
blog: www.pagefault.info
twitter: www.twitter.com/minibobo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-devel/attachments/20110225/ca0836d4/attachment.html>
More information about the nginx-devel
mailing list