okarm
04/09/2021, 12:40 PMHttpClient
is to be treated as a lightweight ephemeral object. Instantiating `HttpClient`s should be done liberally. HttpClient
itself is not resource heavy, all instances manage the underlying installed heavyweight engine in a manner consistent with the proper usage of that engine. Example: OkHttp
engine forks a statically allocated base OkHttpClient
by way of newBuilder()
. Same goes for other engines.
Is the above paragraph true? Assuming the clients are properly closed and all...Marc Knaup
04/09/2021, 9:03 PMHttpClient
across my entire back-end as I’ve experienced them as being quite heavy 😅okarm
04/09/2021, 9:21 PMOkHttp
engine forks an OkHttpClient
led me to believe that Ktor's client is lightweight.
private companion object {
/**
* It's an artificial prototype object
* to be used to create actual clients
* and eliminate the following issue:
* <https://github.com/square/okhttp/issues/3372>.
*/
val okHttpClientPrototype: OkHttpClient by lazy {
OkHttpClient.Builder().build()
}
}
I'll spam this every few days until it gets confirmed or debunked by somebody from Ktor 😅Marc Knaup
04/09/2021, 9:28 PMHttpClient
, when and how is cleanup performed, if at all?Ronald van D
04/10/2021, 3:23 PM