Also, why is the OkHttp engine so slow? 2000k req...
# ktor
m
Also, why is the OkHttp engine so slow? 2000k requests (max 200 in parallel) Apache: ~9s (standard config) Jetty: ~12s (standard config) OkHttp: ~15-36s (1k clients, 1k threads) I’d like to use Apache but it’s unusable (https://youtrack.jetbrains.com/issue/KTOR-717) Jetty also unstable (https://youtrack.jetbrains.com/issue/KTOR-1120) CIO also unstable (https://youtrack.jetbrains.com/issue/KTOR-1126) OkHttp is sloooow… (https://youtrack.jetbrains.com/issue/KTOR-1121)
m
Maybe there's some headers with okhttp that the server takes more time to process? Can you do the same benchmark with
MockHttpServer
to take the server out of the equation?
m
Weird, the Apache engine uses HTTP/1 while OkHttp uses HTTP/2. a) Why is /2 slower than /1? Or is it the different engine? Will test. b) Why does Apache not use /2?
b) Looks like a documentation bug. Documentation states that it supports HTTP/2 but it doesn’t,
Still a major difference between the engines when both use HTTP/1.
g
Apache and jetty based on NIO, Okhttp is blocking, so probably this is why
m
Maybe, yes. I’ve also found out that OkHttp uses GZIP even if I don’t install
ContentEncoding
in the Ktor client.
Sill, a 500% difference is quite hefty. There are enough threads.
I can’t really pick an engine for a high volume of calls 😅 Apache doesn’t support HTTP/2 and freezes randomly. Jetty is full of race conditions. OkHttp has major performance issues. I guess there’s no way around HTTP/1 for now 😞
CIO is as slow as OkHttp Jetty. In tests with localhost CIO is 300% slower than Apache.
g
@Marc Knaup have you tried to set Accept-Encoding: identity for okhttp requests?
m
I’ve set it to an empty header to disable compression. It’s no longer requesting gzip but the result is the same.
Great, CIO also randomly gets stuck completely. Conclusion is that all four engines have severe problems under high load 😞
e
@Marc Knaup, the CIO problem is fixed and will be released in
1.4.2
Could you share the benchmark code? Right know we have automation to monitor performance numbers for server. I'm going to make the same for client
m