<div dir="ltr"><div dir="ltr"><div class="gmail-code gmail-panel" style="margin:9px 0px;padding:0px;border:1px solid rgb(193,199,208);background:rgb(244,245,247);font-size:12px;line-height:1.33333;font-family:monospace;border-radius:3px;color:rgb(23,43,77)"><div class="gmail-codeContent gmail-panelContent" style="margin:0px;padding:9px 12px"><pre class="gmail-code-java" style="margin-top:0px;margin-bottom:0px;padding:0px;max-height:30em;overflow:auto">0.000 sysctl -w net.ipv4.tcp_rmem=<span class="gmail-code-quote" style="color:rgb(0,145,0)">"4096 4096 4096"</span>
0.072 sysctl -w net.ipv4.tcp_rmem=<span class="gmail-code-quote" style="color:rgb(0,145,0)">"512 512 512"</span>
0.106 sysctl -w net.ipv4.tcp_rmem=<span class="gmail-code-quote" style="color:rgb(0,145,0)">"256 256 256"</span></pre></div></div>You're right.<br>This was invaluable, thank you!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 7, 2024 at 11:46 AM J Carter <<a href="mailto:jordanc.carter@outlook.com">jordanc.carter@outlook.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
On Thu, 7 Mar 2024 08:17:23 +0200<br>
Clima Gabriel <<a href="mailto:clima.gabrielphoto@gmail.com" target="_blank">clima.gabrielphoto@gmail.com</a>> wrote:<br>
<br>
> Greetings,<br>
> I'm investigating a bug, super easy to reproduce.<br>
> Thought you might be curious.<br>
> <br>
> Minimal Nginx config. Create two files. 100M and 1M:<br>
> dd if=/dev/zero of=/var/www/file100M bs=100M count=1<br>
> dd if=/dev/zero of=/var/www/file1M bs=1M count=1<br>
> <br>
> Get them files:<br>
> curl --limit-rate 10M -o /dev/null <a href="http://127.0.0.42:80/file100M" rel="noreferrer" target="_blank">127.0.0.42:80/file100M</a><br>
> curl --limit-rate 100k -o /dev/null <a href="http://127.0.0.42:80/file1M" rel="noreferrer" target="_blank">127.0.0.42:80/file1M</a><br>
> <br>
> Both transfers take ~10s, but Nginx logs 0s request_time for the small file.<br>
> <br>
<br>
This isn't an issue with nginx. The response nginx sends<br>
truly does take 0s to reach the client's socket.<br>
<br>
Curl's limit-rate flag only applies at the application layer, but it has<br>
no effect on curl's tcp socket, or it's buffers/how fast things are<br>
read into the buffer. The entire response sent by nginx is being<br>
received into into curl's tcp socket buffer instantly, which is<br>
auto-scaled to a large window size because you are making these<br>
requests from local machine.<br>
<br>
You can temporarily set tcp read window to smallest possible minimum,<br>
default, and maximum to confirm. Like this:<br>
<br>
sysctl -w net.ipv4.tcp_rmem="4096 4096 4096"<br>
<br>
or just view tcp traffic via wireshark.<br>
<br>
> master_process off;<br>
> daemon off;<br>
> error_log /dev/stderr;<br>
> events {}<br>
> http<br>
> {<br>
> log_format req_time "$request_time";<br>
> server<br>
> {<br>
> server_name 127.0.0.42;<br>
> listen <a href="http://127.0.0.42:80" rel="noreferrer" target="_blank">127.0.0.42:80</a>;<br>
> root /var/www/;<br>
> index index.html;<br>
> location /<br>
> {<br>
> access_log /dev/stderr req_time;<br>
> error_log /dev/stderr;<br>
> }<br>
> }<br>
> }<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="https://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">https://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div></div>