Repository navigation
Backpressure on http.ServerResponse #10256
Description
Activity
- addedquestionIssues asking questions about Node.js.Issues asking questions about Node.js.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.
on Dec 13, 2016 you don't have enough data for pressure. The get request has an empty message body! Also, the client may not be reading yet, but the client TCP stack is. It will read enough data to fill its buffer, at which point data will stop flowing until the client app (node) reads data from the TCP stack. In this case, you have no data to speak of, so it all goes across TCP and is buffered in the client stack. Do a giant, giant POST and you may see what you were hopeing for.
I'm only testing back-pressure in the response here, not in the request.
How much is giant?Hmm, it seems like a gigabyte (10003) is the magic number. Above that, I don't get
PASSTHROUGH_END.
Are the TCP buffers really that big?I think it's also the way the pipe's working. If I write the Gb in one go, I get
PASSTHROUGH ENDdisplayed. If I write it in two chunks, each half a Mb then I don't getPASSTHROUGH ENDdisplayed.I guess this is because writing in two chunks gives the pipe a chance (after the first write) to notice that
resis full and therefore pause.... which means the TCP buffers are lower than Gb and I need to do some more testing for the figure on my system.
@sam-github thanks for the pointer.
Localhost TCP buffers might be incredibly high, because on localhost the data buffering cost is all on your host, doesn't matter if its the sender's or the receiver's buffers. I'm not saying it is... but localhost TCP does bypass some TCP protocol lower layers as irrelevant when not running over a network.
You could try over a network. Also, I've never seen the passthrough stream, it could be you are just observing and oddity of it.
If I write 16MB in 2 chunks then I get the backpressure. 16MB seems reasonable.
Here's a test program:
I expected it to display:
because the client-side isn't reading from the response so back-pressure should be applied via
restopthru.However, it actually displays:
I think maybe I'm missing something, or is this a bug?