-
-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Http4k-netty performs really badly on all benchmarks (with lots of errors) #141
Comments
TBH, we are unsure. The Netty backend is:
We would appreciate any help that the community can give in locating the source of the problem. :) |
I've got my hands full right now but if I start using http4k I'll check the TEB repo, maybe I can find something. According to TEB the best performing option is |
@adam-arold I second this approach - Apache would seem to be best option! If there are tweaks to the Apache server implementation that we can make then please let us know - although previously it had been indicated that it works completely OOTB so "mostly" intrigues me.. |
It is not an Apache / http4k problem, but a Substrate problem (reflection is a bit problematic). More about this here. |
According to this tweet, Apache should work with no mod (once again, cannot confirm): http://twitter.com/gyula_voros/status/1009711381510283265 |
Hah, that's funny. I know Gyula personally. I think I'll just talk to him. 👍 I guess you are right. The article I linked was about Netty (which is problematic apparently 😃 ). |
I was able to reproduce http4k-netty benchmark problems on a different http4k microservice and my own benchmarking testbed that also uses When looking at the traffic using Wireshark, I can see that server responses on netty have In addition to hurting performance, this seems to fool wrk's hand-written HTTP parser into reporting read errors for every request (even though the HTTP response seems correct to both me and Wireshark):
Perhaps there is something in the Http4k <-> Netty integration that prevents content-length from being correctly passed? (Netty itself seems to be well capable of persistent connections when used by Ktor) CC @goodhoko. |
That's amazing investigation work - thank you! I wonder if this can be easily fixed somehow - although I'm not totally sure how at the moment to best do this - there may be something built into the Netty APIs which will automatically set the header instead of us just manually doing it. Presumably it should be easy to replicate locally with wrk? The Netty integration is actually only a single file which lives here, so could easily be modified outside the http4k codebase to try and work out the best way: https://github.com/http4k/http4k/blob/master/http4k-server-netty/src/main/kotlin/org/http4k/server/Netty.kt |
I've speculatively made this PR (on a very small response) to set the content-length or the transfer-encoding. Second run on warm JVM:
PR: #480 @strohel Could you try the implementation on this branch and see what the effect is on your test (as it will be a bit more real world than my 5 minute effort.. :) ) |
Thanks for a quick response, @daviddenton. What would be the easiest way to use your branch in my Gradle project? I've tried jitpack.io to try luck, but the build fails there: https://jitpack.io/com/github/http4k/http4k/netty-set-transfer-encoding-or-content-length-ef6164ee52-1/build.log |
the easiest thing is to just copy the entire netty.kt file from the branch into your project and use that version inside the call to asServer() |
Cool, tried it now and I can confirm that the TCP connection is now persistent (netty even adds |
The full benchmark report is here: https://storage.googleapis.com/strohel-pub/bench-http4k-server-engines-excerpt/bench-results.html The summary is that the fix made Netty a very viable server engine. (yay!) Latency-wise it is a clear winner among other engines, at the cost of higher memory demand, apparently. |
that's great! I’ll merge that in and get it released, then get it upgraded into the tech empower benchmark suite. We should see the results in the next few days. As an aside, it might also be worth testing the old apache engine (http4k-server-apache4) and the sunhttp engine that comes with core, just to see how they compare. I’ve a suspicion that apache4 might outperform apache5... 🙃 Thanks again! |
Fixed, to be released in 3.259.0 |
Here you go: https://storage.googleapis.com/strohel-pub/bench-http4k-server-engines-excerpt/bench-results.html
|
I'm seeing similar behavior with slow performance. This occurs with the
Performance looks good if the response is static.
But any stream-like response will trigger the slow performance.
This issue appears in the current release ( |
I've checked the techempower benchmarks and it seems that
http4k-netty
performs really badly and has a lot of errors in the benchmarks. Is this an inherent problem with Netty or is the benchmark bad?The text was updated successfully, but these errors were encountered: