Okhttp: Improve Connection Pool logic and defaults

Created on 16 Jun 2019  ·  3Comments  ·  Source: square/okhttp

5 idle connections seems small for an app that might hit 2 APIs, a few CDNs etc and some external sites.

Specifically closing a bunch of HTTP/2 connections to retain the last 5 HTTP/1.1 connections to a single site seems odd.

image

enhancement

Most helpful comment

This is a good space for mid sized companies to improve their app performance. And therefore a high value space above basic submit a HTTP request for me, for OkHttp to provide value.

It's pretty obvious from java.net.http and Android cronet, that they want to hide any details like that because they can do a good job optimising the default with an API with minimal surface API. But not the best for any infra team at a tech company trying to improve app performance.

I'm still plugging along on https://github.com/yschimke/OkHttpAndroidApp/, specifically how to optimize the performance and behaviour e.g. Conscrypt, warmed connections etc.

class Config(
        val optimised: Boolean = true,
        val useCache: Boolean = true,
        val ctHosts: List<String> = listOf(),
        val conscrypt: Boolean = true,
        val cacheSize: Long = 1024 * 1024 * 64L,
        val quicHosts: List<String> = listOf(),
        val hotHosts: List<String> = listOf(),
        val closeInBackground: Boolean = true,
        val warmedConnections: List<String> = listOf())

All 3 comments

FYI I know the defaults are tunable, but the logic isn't.

I wanna build a small, high leverage API to let users control both connection pooling and client side load balancing.

This is a good space for mid sized companies to improve their app performance. And therefore a high value space above basic submit a HTTP request for me, for OkHttp to provide value.

It's pretty obvious from java.net.http and Android cronet, that they want to hide any details like that because they can do a good job optimising the default with an API with minimal surface API. But not the best for any infra team at a tech company trying to improve app performance.

I'm still plugging along on https://github.com/yschimke/OkHttpAndroidApp/, specifically how to optimize the performance and behaviour e.g. Conscrypt, warmed connections etc.

class Config(
        val optimised: Boolean = true,
        val useCache: Boolean = true,
        val ctHosts: List<String> = listOf(),
        val conscrypt: Boolean = true,
        val cacheSize: Long = 1024 * 1024 * 64L,
        val quicHosts: List<String> = listOf(),
        val hotHosts: List<String> = listOf(),
        val closeInBackground: Boolean = true,
        val warmedConnections: List<String> = listOf())
Was this page helpful?
0 / 5 - 0 ratings