How does using multiple sessions affect NSURLSession’s Resume Rate Limiter?

In post https://forums.developer.apple.com/thread/14854 the Resume Rate Limiter behavor is described in terms of batches of tasks. How do mutiple sessions affect this behavior? Is there any difference in behavior between an app submitting batches of 300 sessions, each containing 1 task, and the same app submitting batches of 1 session, each containing 300 tasks?


(Not trying to be lawyerly, just trying to understand. My app's currently using the 300 sessions of 1 task each approach. It's an embarasingly large chage to refactor my code to support 1 session of 300 tasks. I would love to know ahead of time whether performance would be improved if I did that. I'm only concerned about the behavior of iOS 8.3+ for this feature, due to other constraints.)

Accepted Answer

Is there any difference in behavior between an app submitting batches of 300 sessions, each containing 1 task, and the same app submitting batches of 1 session, each containing 300 tasks?

The resume rate limiter applies to your app as a whole, not to any specific session within your app.

My app's currently using the 300 sessions of 1 task each approach.

Yowsers! That’s a really bad idea, regardless of its effect on the resume rate limiter. I talked a little about this in another recent thread but the situation is worse with background sessions because they have a footprint in both the app and

nsurlsessiond
.

It's an embarasingly large chage to refactor my code to support 1 session of 300 tasks.

Oh, and you thought I’d let you get away with that one, eh? (-:

In my experience the majority of folks who are using a session per request do so because of NSURLSession’s single delegate (as opposed to the NSURLConnection model, where there is one delegate per request). However, it’s relatively easy to demultiplex the NSURLSession delegate. The QNSURLSessionDemux class in the CustomHTTPProtocol sample code shows one technique you can use

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
How does using multiple sessions affect NSURLSession’s Resume Rate Limiter?
 
 
Q