async-http-client icon indicating copy to clipboard operation
async-http-client copied to clipboard

OOM if setting `concurrentHTTP1ConnectionsPerHostSoftLimit: .max`

Open weissi opened this issue 1 year ago • 0 comments

I would like to make the pool create as many concurrent connections as possible. So I thought the best way of spelling this is

        var httpClientConfig = HTTPClient.Configuration()
        httpClientConfig.connectionPool = .init(
            idleTimeout: .hours(1),
            concurrentHTTP1ConnectionsPerHostSoftLimit: .max
        )
        httpClientConfig.timeout = .init(connect: .seconds(10), read: .seconds(100), write: .seconds(100))

unfortunately, the concurrentHTTP1ConnectionsPerHostSoftLimit: .max makes AHC OOM even before it creates any connections because HTTPConnectionPool.HTTP1Connections.init() preallocates an array of that size.

It shouldn't do that or at least cap it to something reasonable like 1024.

weissi avatar Jul 17 '24 14:07 weissi