<This blogpost> makes me suspect that the generate...
# dev
a
This blogpost makes me suspect that the generated Java API client does not reuse HTTP connections: we probably get a new SSL Socket Factory each time we create an API client, which prevents reuse.
😬 1
Relevant scary lines in ApiClient.java:
Copy code
SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(keyManagers, trustManagers, new SecureRandom());
            httpClient = httpClient.newBuilder()
                            .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0])
                            .hostnameVerifier(hostnameVerifier)
                            .build();
I see this:
Copy code
OkHttpClient.Builder builder = new OkHttpClient.Builder();
        builder.addNetworkInterceptor(getProgressInterceptor());
This adds a different progress interceptor to each ApiClient, so it seems very likely that OkHttp will generate a different HTTP client each time. And that means we won't re-use connections.
... and OkHttpClient.kt says:
Copy code
* ## OkHttpClients Should Be Shared
 *
 * OkHttp performs best when you create a single `OkHttpClient` instance and reuse it for all of
 * your HTTP calls. This is because each client holds its own connection pool and thread pools.
 * Reusing connections and threads reduces latency and saves memory. Conversely, creating a client
 * for each request wastes resources on idle pools.
 *
 * Use `new OkHttpClient()` to create a shared instance with the default settings:
So https://github.com/treeverse/lakeFS/issues/3995, and verify we do the same in LakeFSFS I guess.