I've run some tests and I'm pretty sure the reason I was getting 5MB stuck on nginx side was because of RCVBUF on upstream socket uses default socket buffers and by default it ends up with 5MB RCV buffer. I added logs to check that value and even after I configured sndbuf and rcvbuf inside listen directive I was getting 5MB buffer on upstream socket. After I configured these buffers on upstreamby Dan34 - Nginx Mailing List - English
Yes, I tested that and it appears to be the case. However, I don't see where nginx sets rcvbuf on the upstream socket as this one cannot be inherited. Somehow even with SND/RCV buffers set to low values and buffering disabled I get around 2.5BM stuck on nginx side. With my own simple proxy I get perfect results: when socket buffers are low there is no data accumulated on the proxy side.by Dan34 - Nginx Mailing List - English
In nginx docs I see sndbuf option in listen directive. Is there something that I don't understand about it, or developers of nginx don't understand meaning of sndbuf... but I do not see a point to set sndbuf on a listening socket. It just does not make any sense! sndbuf/rcvbuf is needed perhaps for an upstream proxy connection, or for a connected socket (from outside), but it just have no meaninby Dan34 - Nginx Mailing List - English
It looks like for localhost buffers are bigger, but even if it's not local host I do get 5MB stuck in socket buffers. I was only able to get perfect results by writing my own proxy in c and doing some obscure nodejs code to avoid buffering. In any case, if nginx does not provide a way to control sockets buffer I cannot use it. For example, 'X-Accel-Buffering: no' supposedly disables caching (Iby Dan34 - Nginx Mailing List - English
I did some logs on my proxy test and compared results with wireshark trace at some random point in time (t=511sec) And numbers match exactly between logs and wireshark. This is a log line from my test proxy: time: 511s, bytesSent:5571760, down:{ SND:478720 OUTQ:280480 } up:{ RCV:5109117 INQ:3837047 } SND is SNDBUF, RCV is RCVBUF, OUTQ is SIOCOUTQ, INQ is SIOCINQ/FIONREAD. down is the linkby Dan34 - Nginx Mailing List - English
I wrote my own proxy and it appears that the data is all stuck in socket buffers. If SNDBUF isn't set, then OS will resize it if you try to write more data than remote can accept. Overall, in my tests I see that this buffer grows to 2.5MB and in wireshark I see that difference grows up to 5MB. As docs from SO_SNDBUF state, actual internal value is usually twice larger than what SO_SNDBUF ports theby Dan34 - Nginx Mailing List - English
> You should check tcpdump (or wireshark) to see where actually 12.5MB > of data have been stuck. Wireshark confirms my assumption. All the data is buffered by nginx. More over, I see some buggy behavior, and I've seen that happen quite often. This is localhost tcp screenshot: http://i.imgur.com/9Rz6Acs.png You can see that after 1327 seconds nginx ACKed 18.5MB (which is 13.9MB/s).by Dan34 - Nginx Mailing List - English
Hello Valentin, > 1. Write socket buffer in kernel on node.js side where node.js writes data. we can throw this out from equation, as I measure my end time by the event when socket is closed on nodejs side, (I use http1.0 from nginx to node to make it simple for this case). > 2. Read socket buffer in kernel for node.js connection from what nginx reads data. SO_RCVBUF shouldn't beby Dan34 - Nginx Mailing List - English
> Depending on the compromises you are willing to make, to accuracy or > convenience, you may be able to come up with something good enough. I have a more or less working solution. nginx breaks it and I'm trying to figure out how to fix it. > Yes. That is (part of) what a proxy does. Even without nginx as a > reverse-proxy, your client might be talking through one or more proby Dan34 - Nginx Mailing List - English
> X-Accel-Buffering: no > That will disable nginx's buffering for the request. At first it looked like exactly what I was looking for (after reading nginx docs), but after trying I observed that there were no effects from that. In code that writes headers I added res.setHeader('X-Accel-Buffering', 'no');by Dan34 - Nginx Mailing List - English
Hi Francis, > Are you concerned about the request or the response being buffered? my problem is that response that my node app (upstream server) generates is buffered by nginx. My actual goal is to know speed and amount of data that my node app sent to a client. So, when I sent 20MB binary blob from node I can wait till data is sent out and I'll know approximate speed and size. The momenby Dan34 - Nginx Mailing List - English
No matter what configs I try, nginx still keeps buffering my requests. These are the configs that I apply in my test: ``` proxy_pass http://localhost:80; proxy_request_buffering off; proxy_buffer_size 4k; proxy_buffers 8 4k; proxy_no_cache 1; proxy_set_header Host $host; proxy_max_temp_file_size 0;``` in my case I run nodejs appby Dan34 - Nginx Mailing List - English
just to add up, I obviously tried to compare $http_host and it doesn't work: server { listen 80; location / { return 444; # drop connection silently } location /data/ { if ($http_host != "") { return 444; } alias /home/http/; try_files $uri $uri.html =404; } } server { listen 80; server_name example.com; location /datby Dan34 - How to...
HI, if I use default catch all block to drop connections and then another server block with my name then everything kind of works: server { listen 80; location / { return 444; # drop connection silently } } server { listen 80; server_name example.com; location /data/ { alias /home/http/; try_files $uri $uri.html =404; } } Noby Dan34 - How to...