Welcome! Log In Create A New Profile

Advanced

Rate Limit with multiple subrequests

Umesh Sirsiwal
May 02, 2011 07:12PM
ngx_http_write_filter module has the following code for rate limit.
if (r->limit_rate) {
limit = r->limit_rate * (ngx_time() - r->main->start_sec + 1)
- (c->sent - clcf->limit_rate_after);

Looking at the code, it seems the start_sec is overwritten for each
subrequest.
ngx_int_t
ngx_http_subrequest(ngx_http_request_t *r,
ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr,
ngx_http_post_subrequest_t *ps, ngx_uint_t flags)

tp = ngx_timeofday();
r->start_sec = tp->sec;
r->start_msec = tp->msec;

The implication is that the rate limit is off when we have multiple
subrequests. Shouldn't the above be:
sr->start_sec = tp->sec;
sr->start_msec = tp->msec;


-Umesh

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Rate Limit with multiple subrequests

Umesh Sirsiwal 2146 May 02, 2011 07:12PM

Re: Rate Limit with multiple subrequests

Maxim Dounin 916 May 03, 2011 08:36AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 235
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready