URLSession HTTPMaximumConnectionsPerHost default change in iOS 15/macOS 12
0 reputation · 05 Nov 2024, 04:09 UTC
When iOS 15 and macOS 12 raised the default HTTPMaximumConnectionsPerHost from 4 to 6, developers observed intermittent latency spikes and timeouts during burst traffic. The goal is to determine whether the per‑host connection pool is truly isolated per URLSession or if multiple sessions share sockets, especially when using background sessions or URLSessionStreamTask.
Constraints include that URLSessionConfiguration is immutable after initialization, and the pool limit applies to HTTP/1.1 and HTTP/2 connections only. Uncertainty remains about how background sessions count against the same host’s limit and whether stream tasks are included in the pool size.
Questions: 1) Does each URLSession, including background sessions, maintain an independent pool of up to HTTPMaximumConnectionsPerHost connections? 2) Are URLSessionStreamTask connections counted against the pool limit for the host? 3) Is there any scenario where sockets from different session types are shared, potentially causing exhaustion beyond the documented per‑session limit?