Re: URLSession on iOS 10
Re: URLSession on iOS 10
- Subject: Re: URLSession on iOS 10
- From: Shawn Erickson <email@hidden>
- Date: Wed, 23 Nov 2016 16:16:03 +0000
Sorry for top posting ... googles inbox on iPad makes it really hard to do anything other then top post...
We throttle for 3 main reasons. 1) Starting many requests - in our experience - results in a far higher likelihood of requests randomly timing out. It seems like the timeout starts ticking relative to creation of the task - possibly initial resume - and not after some internal throttling takes place. That makes firing off a large number of requests a little to non deterministic. We can arbitrarily bump the data timeout to hide this issue but we don't like that for other reasons. 2) We are predictively loading JSON blobs (some large or paginated) and file data (images, etc.) as the user navigates around our app. As a result we need to reprioritize, adjust dependencies, and/or cancel queued requests on demand. This can't be done effectively enough at the session level but can be done at operation queue level. We do also use the priority knobs provided by session tasks but those are documented as being advisory more then concrete. 3) If we have authentication challenges and similar system state changes pop up from active tasks we can more easily inform/adjust not yet started tasks.
Anyway I jumped into this thread to both help another developer (and you if possible) as well as poke at what we have to see if we also have a lurking issue that could bite us. I will test a little more with our stuff but we are likely operating with a sufficiently different request profile to not hit this issue.
-Shawn
On Wed, Nov 23, 2016 at 1:01 AM Quinn "The Eskimo!" <
email@hidden> wrote:
On 23 Nov 2016, at 00:47, Shawn Erickson <email@hidden> wrote:
> I throttle things using an operation queue set to 10 current operations …
To be clear, NSURLSession was designed to /not/ require the client to throttle requests. You should be able to dump as many requests as you like into a session and NSURLSession throttles them internally.
The only place where this doesn’t hold true is background sessions, where the bookkeeping associated with the background session means that starting many thousands of requests engenders a noticeable performance penalty. In general, I recommend that you use fewer, larger requests in a background session, as explained by the following post.
<https://forums.developer.apple.com/thread/14853>
Now, if you want to throttle requests for other reasons that’s absolutely fine. However, you shouldn't /need/ to do that.
* * *
@Rick Mann, It seems like something is going wrong with NSURLSession here. I’d appreciate you filing a bug about this. It’d be great if you could include a small test project that illustrates the issue.
<https://developer.apple.com/bug-reporting/>
Please post the bug number, just for the record.
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden