Reputation:
Why it could be that OkHttp does not keep an idle connection in the pool for the keep-alive duration? That results in connection count spiking back and forth much faster than actual keep alive duration.
There's only one host with just 1 rps. maxIdleConnections
is set to 20, keepAlive
is set to 20 minutes. The latencies though might reach up to 2 seconds per call.
Connection count is spiking from 1 to 3 and back constantly, like every few minutes.
Upvotes: 2
Views: 2790
Reputation: 40593
Have you configured maxIdleConnections
? If you're hitting lots of hosts then OkHttp will close connections to stay within that limit.
https://square.github.io/okhttp/4.x/okhttp/okhttp3/-connection-pool/-init-/
Upvotes: 2