Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mobile : one single request or multiple smaller requests?

On an iPhone app (or mobile in general) that constantly needs to send requests to a Web Service, is it better to work with one single requests that will fetch a large amount of data or multiple (possibly simultaneous) requests for each element with smaller amount of data fetched.

Example

I want to load a list of elements in a node. I have the node's ID. The 2 ways I can fetch the elements are the following :

  • send a single request with the node ID and get all the information about the n first elements in the node in a single response ;
  • send a first request with the node ID to get the IDs of the n first elements in the node, then for each one send another request to have one response per element.

I'm balanced between about that.

  • the heavyweight single response may cause more lag and timeouts because of the very unstable and slow mobile internet connection ;
  • the phone may have trouble handling too many responses at the same time.

What's your opinion ?

like image 891
scalbatty Avatar asked Jul 01 '11 13:07

scalbatty


2 Answers

Since there is overhead for every request, one large request is generally faster than several small ones of the same size. This applies to high speed networks too, but in mobile networks the ratio between transfer speed and latency is even bigger.

like image 185
Martin Vilcans Avatar answered Oct 01 '22 02:10

Martin Vilcans


I don't think the phone will have any problem handling the responses, so the multiple requests approach seems better for large requests/answers. However, depending on the size of your requests/responses, it may actually be faster to do it in a single request, in order to reduce the delay associated with multiple requests. The single request approach will also need to transfer slightly less data than the multiple request one.

like image 39
Vitor Avatar answered Oct 01 '22 02:10

Vitor