<div dir="ltr"><div>Hi Robert,</div><div dir="auto">Thanks for bringing this up! We are aware of the issue, it's tracked under <a href="https://bugs.openjdk.org/browse/JDK-6968351" target="_blank">https://bugs.openjdk.org/browse/JDK-6968351</a>.</div><div dir="auto"><br></div><div dir="auto">If you have an idea for a proper fix that doesn't add too much complexity, please open a PR, and we'll be happy to help.</div><div>Cheers,</div><div>Daniel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">czw., 4 kwi 2024, 14:55 użytkownik Robert Engels <<a href="mailto:rengels@ix.netcom.com" target="_blank">rengels@ix.netcom.com</a>> napisał:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="ltr"><div dir="ltr">When doing some testing on <a href="http://github.com/robaho/httpserver" rel="noreferrer" target="_blank">github.com/robaho/httpserver</a> - which is a fork of the jdk http server, I discovered a significant performance issue.<div><br></div><div>When an http connection is in ‘keep-alive’ - the default for http 1.1 - the headers are “flushed” here <a href="https://github.com/openjdk/jdk21/blob/890adb6410dab4606a4f26a942aed02fb2f55387/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java#L281" rel="noreferrer" target="_blank">https://github.com/openjdk/jdk21/blob/890adb6410dab4606a4f26a942aed02fb2f55387/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java#L281</a></div><div><br></div><div>This means that after the handler runs and it sends data - e.g. /hello sends “hello” on the connection, the connection will stall due to the Nagel algorithm - usually incurring a 50 ms delay. The stall occurs since the client will not see the expected data until after the delay, so it is unable to send the next (when reusing the same connection/HttpClient).</div><div><br></div><div>You can set the TCP_NODELAY on the server to work-around this, but a better solution would be to override the flush() on the BufferedOutputStream to not flush() the underlying connection - i.e. only write the buffered bytes, or rework it a bit to only flush when there is no content to send.</div><div><br></div></div><div dir="ltr"></div></div></div></blockquote></div>