4 ms·
Nagle is fine for web, as long as you flush when you reach the end of your request/response. And at strategic places like end of headers, end of html head, etc,
by toast0 6y ago
Nagle is fine for web, as long as you flush when you reach the end of your request/response. And at strategic places like end of headers, end of html head, etc, if you know the content isn't directly forthcoming.
A lot of HTTP software writes things to sockets in small chunks though, especially headers and what not. I've seen some things with chunked encoded posts; I don't think it was visible at the TCP level, but I would get three TLS application data segments, one for $SIZE\r\n, one for the size worth of data, and one for the trailing \r\n. Ugh.
- reitzensteinm 6y agoBut it's there, as I understand it, mainly to combine multiple logical packets over a short human sized time scale. By its nature it also prevents fragmenting poorly written logical packets. But you could also do this as a separate level of protection. Say a 5ms delay on any write without a flush, any further write resets the delay, up until a maximum of 20ms. This would seem to reign in the worst of the behavior - developers not realizing they're sending multiple packets - without adding a large delay to developers using the system properly but not flushing. And since the penalty is much less, it would be less likely to be turned off aggressively, see the Go example in sibling comments. If the goal is to hand training wheels to developers of shitty apps, it's pretty important they actually use them.