swift-server/async-http-client

OOM if setting `concurrentHTTP1ConnectionsPerHostSoftLimit: .max`

weissi opened this issue · 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.