Performance problems with Http2
mrozk opened this issue · comments
Hi! Guys, it seems that OkHttpClient has problems with performance on HTTP_2. We are testing HTTP_2 on our microservices. Our client uses Feign and Spring Cloud Loadbalancer under the hood and we added OkHttpClient with HTTP_2 enabled(PRIOR_KNOWLEDGE). Our downstream service is a cluster of 120 pods. We saw that resource consumption was increased several times, especially threads count. We did a thread dump and saw, that OkHttpClient creates a thread per a connection, although OkHttpClient with HTTP_1 doesn't do it.
Did we do something wrong during the OkHttpClient configuration, or is it normal library behavior?
Yes, one thread per connection is expected. Is this causing performance problems beyond the thread use?
Thanks for answering. Actually, 250 running threads instead of 50, is already a performance problem, which causes extra context switching, etc. I believe that switching on http/2 should save resources, not increase its consumption several times.
Actually, we don't have such a situation using http/1 with OkHttp, that's why I'm asking.
Yeah, for HTTP/1 OkHttp doesn’t need a thread to wait on the inbound socket in case a frame arrives. For HTTP/2 we need a thread per socket. It’s usually not a problem because usually the number of HTTP/2 connections isn’t substantial.
One potential fix for this is Project Loom, wherein a waiting thread doesn’t cost many resources.
Closing, as this is intended and not something we can fix until Loom.