Connection pool slot release behavior when cancelling HTTP requests in Symfony 6.x
0 reputation · 01 Feb 2022, 01:24 UTC
Goal
Determine whether cancelling a pending HTTP client request immediately returns its connection pool slot to the pool or defers release until garbage collection.
Constraints and uncertainty
The HTTP client supports cancellation via HttpClient::cancel() on a pending response, which closes the underlying stream. However, the documentation does not specify if the associated connection pool slot is released synchronously. Under high cancellation rates, deferred release could lead to pool exhaustion because slots remain occupied until the garbage collector runs.
Specific questions
- Does
HttpClient::cancel()guarantee immediate return of the connection pool slot in Symfony 6.x? - If release is deferred, what configuration or code patterns ensure deterministic slot reclamation under load?
- Are there differences in slot release behavior between the native PHP streams transport and the cURL transport when a request is cancelled?