Don't delete timer of write event when it's delayed.
Jiuzhou Cui
jiuzhoucui at 163.com
Wed Dec 27 12:38:15 UTC 2023
Thank you for your reply.
Firstly, we meet the problem. And this patch works for me.
My scenario is after send response body about 10-20MB, we just set:
1. limit_rate = 1KB
2. limit_rate_after = body_bytes_sent
3. proxy_buffering = "on" (I think this is the key issue)
At the request begining, we didn't set proxy_buffering = "on" and limit_rate.
At 2023-12-27 19:19:01, "Maxim Dounin" <mdounin at mdounin.ru> wrote:
>Hello!
>
>On Wed, Dec 27, 2023 at 10:56:44AM +0800, Jiuzhou Cui wrote:
>
>> Hello!
>>
>>
>> # HG changeset patch
>> # User Jiuzhou Cui <cuijiuzhou at alibaba-inc.com>
>> # Date 1703645578 -28800
>> # Wed Dec 27 10:52:58 2023 +0800
>> # Node ID 474ae07e47272e435d81c0ca9e4867aae35c30ab
>> # Parent ee40e2b1d0833b46128a357fbc84c6e23be9be07
>> Don't delete timer of write event when it's delayed.
>>
>>
>> This will make download speed alway zero when limit_rate in body filter.
>>
>>
>> diff -r ee40e2b1d083 -r 474ae07e4727 src/http/ngx_http_upstream.c
>> --- a/src/http/ngx_http_upstream.c Mon Dec 25 21:15:48 2023 +0400
>> +++ b/src/http/ngx_http_upstream.c Wed Dec 27 10:52:58 2023 +0800
>> @@ -3787,11 +3787,13 @@
>> }
>> }
>>
>>
>> - if (downstream->write->active && !downstream->write->ready) {
>> - ngx_add_timer(downstream->write, clcf->send_timeout);
>> -
>> - } else if (downstream->write->timer_set) {
>> - ngx_del_timer(downstream->write);
>> + if (!downstream->write->delayed) {
>> + if (downstream->write->active && !downstream->write->ready) {
>> + ngx_add_timer(downstream->write, clcf->send_timeout);
>> +
>> + } else if (downstream->write->timer_set) {
>> + ngx_del_timer(downstream->write);
>> + }
>> }
>>
>>
>> if (upstream->read->eof || upstream->read->error) {
>
>Thank you for the patch.
>
>You are patching the
>ngx_http_upstream_process_non_buffered_request() function, which
>is, as can be correctly concluded from the function name, is used
>for non-buffered proxying. Non-buffered proxying is specifically
>designed to return responses as long as they are available, and is
>not compatible with limit_rate. Moreover, limit_rate is
>explicitly disabled in the ngx_http_upstream_send_response()
>function when the relevant handers are set:
>
> u->read_event_handler = ngx_http_upstream_process_non_buffered_upstream;
> r->write_event_handler =
> ngx_http_upstream_process_non_buffered_downstream;
>
> r->limit_rate = 0;
> r->limit_rate_set = 1;
>
>(https://hg.nginx.org/nginx/file/release-1.25.3/src/http/ngx_http_upstream.c#l3092)
>
>As such, the issue you are trying to fix is not expected to
>appear.
>
>Could you please clarify the configuration you are seeing the
>issue with, and steps to reproduce the issue?
>
>--
>Maxim Dounin
>http://mdounin.ru/
>_______________________________________________
>nginx-devel mailing list
>nginx-devel at nginx.org
>https://mailman.nginx.org/mailman/listinfo/nginx-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20231227/cf86e895/attachment.htm>
More information about the nginx-devel
mailing list