ArielB
ArielB

Reputation: 1274

RestKit network limits blocks other calls when parallel requests are running

we are facing a problem. we have background requests that are downloading files constantly (up to 5MB each file). meanwhile, we have a UI that most navigations require REST calls.

we limited the number of background downloads so it won't suffocate the operationQueue that RESTkit uses.

when several files are downloaded in background, we see the network usage with 1->2 MB (which is understandable).

The problem is: the user navigates through the app, and each navigation calls a quick REST call that should return very little data. but because of the background downloads, the UI call is taking forever (~10 seconds).

Priority did not help, i saw that the UI call i make instantly is handled by the operation queue (because we limited the downloads limit and the NSOperationQueue had more space to fulfill other requests.

when we limited the concurrent REST download calls to 5 - the REST calls from the UI took 10 seconds. when we limited the concurrent REST download calls to 2 - everything worked fine.

the issue here is that because we let only 2 downloads occur in the background - the whole background operation of downloading files will take forever.

the best scenario would be that every UI call would be considered as most important network-wise and even pause the background operations and let only the UI call to be handled - then resume the background operation - but i'm not sure it's possible.

any other idea to address this issue?

Upvotes: 1

Views: 315

Answers (1)

Wain
Wain

Reputation: 119031

You could use 2 RKObjectManagers so that you have 2 separate queues, then use one for 'UI' and the other for 'background'. On top of that you can set the concurrent limits for each queue differently and you could suspend the background queue. Note that suspending the queue doesn't mean already running operations are paused, it just stops new operations from being started.

By doing this you can gain some control, but better options really are to limit the data flow, particularly when running on a mobile data network, and to inform the user what is happening so they can accept the situation or pause it till later.

Upvotes: 1

Related Questions