<@U0PQ0GVLM>'s groundbreaking article unveils the ...
# feed
h
@marcinmoskala's groundbreaking article unveils the shocking truth about thread usage in popular Kotlin network clients. The results will revolutionize your approach to optimizing applications with Kotlin Coroutines https://kt.academy/article/network_client_threads
🔥 7
b
I find this article misleading, in the beginning it says
However, our efforts are often sabotaged by libraries we use. In this article, I present how many threads the most popular network clients use, and how you can check it yourself.
And results say Retrofit/Ktor okhttp/Fuel (all three are okhttp-based) are the most expensive (in terms of thread count) libraries. But why? The answer is simple, the author configured it this way so it has nothing to do with libraries' default options. Author directly configured it as "do each request in a separate thread". Using the defaults it would be 5 concurrent requests per host (no much difference comparing with other libraries). So the results make no sense and comparison is not fair
m
@bezrukov It I used default, fetching those data for 500 requests would take 100 seconds, while all other clients would need only 3 seconds. Read introduction, we simulate a situation where a system needs to make a lot of requests, and limitation to 5 or 50 active calls is not enough. That is a situation we are dealing with in services with huge load, that for requests need to await data from other services or DB. Not uncommon in distributed microservices, or even more for services that communicate with third party API.
But even if there is a small number of requests, Retrofit blocks more threads than, say, Ktor Client with Java engine, no matter how I configure it.