If you specify the maxConcurrentOperationCount
of the operation queue, that will control how many concurrent operations are attempted, thus mitigating any timeouts resulting from the fact that iOS limits how many simultaneous network connections are permitted:
manager.operationQueue.maxConcurrentOperationCount = 4;
[manager.operationQueue addOperations:operations waitUntilFinished:NO];
In the absence of this, when you submit your 40 operations, all of them are likely to attempt to start NSURLConnection
objects, even though only 4 or 5 can really run at at a time. On slow connections, this can result in some of your latter requests timing out.
If you specify the maxConcurrentOperationCount
, it won't attempt to start the latter connections until the prior connections have completed. You'll still enjoy the performance benefit of concurrent requests, but you won't be making a bunch of requests that will timeout because of the throttling of concurrent NSURLConnection
requests that iOS enforces.