Atma
Atma

Reputation: 29767

Is it better for performance to download data in one large request or multiple small requests on mobile devices?

I have a mobile app written for iOS and Android that is using a single web service for returning data. The data returned by this service change approximately once per day or when a user changes locations. I am currently downloading a single large message (around 700kb) and populating the app with all the data it will need for a user session.

The problem is that the initial message takes about 30 seconds to process all of the data into the local database (sqlite) tables. This has lead me to consider downloading smaller chunks of data and processing the data as needed? This will likely cause small wait times on each click within the app.

What is the optimum approach based on performance which in turn translates to the best user experience for the type of scenario I have explained above?

I have seen other questions like this but they lack definitive answers. Please supply any answer/opinion and then please vote so we can put this argument to rest!

Upvotes: 1

Views: 1121

Answers (2)

Wolfram Rittmeyer
Wolfram Rittmeyer

Reputation: 2402

In general one HTTP request is best for the reason whiteagle has given. But if for the first Activity only a small amount of data is useful, you should consider splitting the downloads. Load only what is initially needed directly and use this information to update (!) the first screen.

After the request returns immediately start to download all the other stuff in one subsequent request. If the information of the first screen is useful the user will take at least a short while before progressing to the next view.

Of course you should heed the usual best practices:

  • Do all downloading in the background.

  • Show the user something, even while the download hasn't completed - then update the UI after the download.

  • Try to minimize downloads in that only what is really new is downloaded.

  • And most importantly: Cache aggressively.

Upvotes: 1

whiteagle
whiteagle

Reputation: 1158

Definitely, from the response time point of view, its better to use one connection with one fetch request. In mobile environment there is almost no DNS caching, keep-alive checks, etc, etc (all these small things which make our life easier on PCs), so each connection establishment (handshake) takes quite a while, up to one second in some cases. So, if you split the feed in different connections you'll have to sum up all the handshakes.

In your case you state there is a processing delay problem, so, may be it would be a good idea to put this process into background thread and fill the data in chunks ? I mean, you download entire feed and launch processing routine in steps of 100 (for example) with some return.

Upvotes: 1

Related Questions