DynamoDB Connection Pool Exhaustion: Raise maxConnections or Tighten Retry/Backoff?
0 reputation · 22 Nov 2022, 21:50 UTC
0 reputation · 22 Nov 2022, 21:50 UTC
In AWS SDK for Java v2, DynamoDB clients can intermittently exhaust the HTTP connection pool when request bursts outpace socket release. Two documented adjustments are often considered: increasing the maximum pool size via ApacheHttpClientBuilder.maxConnections, or tightening the retry policy with exponential backoff and jitter. Each has trade-offs.
Raising maxConnections permits more concurrent sockets, reducing lease contention, but increases client memory use and can amplify throttling if DynamoDB provisioned throughput is already saturated. Tightening retry/backoff lowers the rate of new requests during throttling, giving the pool time to recover, yet may add latency and starve requests under sustained load. The optimal balance depends on traffic burst patterns and table capacity.
An unresolved behavior is whether the async client reliably closes idle connections after connectionTimeToLive during network interruptions; if leaked sockets persist, pool exhaustion may continue despite either adjustment. This point may require verification against current SDK behavior.
Which adjustment should be prioritized for intermittent pool exhaustion: raising maxConnections or tightening retry/backoff? How should the two be combined when the workload is bursty but provisioned throughput is fixed? And does the async client’s idle-connection handling change the answer?
33275 reputation · 23 Nov 2022, 00:36 UTC
Prioritize tightening the retry/backoff policy. This reduces the request rate that hits DynamoDB during throttling, giving the HTTP pool time to release sockets. Only if the pool still reaches maxConnections during a burst should you increase that limit. The async client’s idle‑connection handling (connectionTimeToLive) only matters if you suspect sockets are leaking; if they are, neither adjustment will help until the leak is fixed.
maxConnectionsmaxConnections. If it does, raise the pool size in small increments.The async client closes idle sockets after connectionTimeToLive (default 60 s). If network interruptions prevent proper closure, sockets can leak and keep the pool full. Verify this by enabling Netty channel leak detection or Apache HttpClient’s idle‑connection monitor. If leaks are present, fix the underlying network issue or adjust connectionTimeToLive before tweaking the pool or retry policy.
What was the observed peak concurrent request count during a burst, and what is the current maxConnections setting? If the peak never exceeds the pool size, raising maxConnections is unnecessary and the focus should remain on retry/backoff.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.