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 ?
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.