https://kotlinlang.org logo
#ktor
Title
# ktor
m

Marc Knaup

10/09/2020, 10:24 PM
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

mbonnin

10/10/2020, 8:46 AM
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

Marc Knaup

10/10/2020, 12:55 PM
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

gildor

10/10/2020, 2:00 PM
Apache and jetty based on NIO, Okhttp is blocking, so probably this is why
m

Marc Knaup

10/10/2020, 2:07 PM
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

gildor

10/10/2020, 3:16 PM
@Marc Knaup have you tried to set Accept-Encoding: identity for okhttp requests?
m

Marc Knaup

10/10/2020, 3:17 PM
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

e5l

10/12/2020, 1:41 PM
@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

Marc Knaup

10/12/2020, 2:35 PM
3 Views