views:

52

answers:

2

I have an iPhone app that grabs information from different sources in XML format. For example i have a UITableView displaying information, in xml format after being parsed, from an url like this one http://mysite.com/posts.php?top=100 -> returns posts information like this

<postsList><post><title>test1</title><pubDate>..</pubdate></item><post><title>test1</title><pubDate>..</pubdate></item></postsList>

so i have one request only for showing the table with posts. when i click on a cell i have to make three calls to three different sources to gather the data i want to show in the details of the cell.

I was thinking to write some ASP.NET C# webservices that, when called, gather all the info i need and return a single response(so i make one request) when i show the initial UITableView.

The xml response will have 10-15kb max with all the data included. From my experience network access(wireless or 3g) is expensive on the iphone from the performance point of view and if possible i would like to avoid it if it's not necessary.

So the question is: is it a good idea to get as much data as possible from a single request or is it better to make requests only when data is needed(in this case when a cell is displayed)?

+3  A: 

If you're on a slow cellular connection, the latency will hurt you more than the limited bandwidth. This means that setting up a connection will take a lot of time because of the latency. If you're talking about 10-15 kb, I would get all the data at once (of course, you should do that asynchronously)

Let's say you're on a GPRS connection, which is 384kbps (in our country at least). The latency is in the order of 500ms, so setting up a HTTP connection could take about 1 second (best case). Transfer speed is about 40KB/s.

Using a single download:

  • 1 second setup + 0.5 second download = 1.5 seconds

Using 10 small downloads:

  • 10 x 1 second setup + 10 x 0.05 second download = 10.5 seconds

This is not a scientific test, but it simply shows how you should tackle these kind of decisions.

Philippe Leybaert
the data is downloaded async using ASIHTTPRequest. so in short is a good idea to write the .net webservices and get the data all at once.
SorinA.
I would definitely get all the data at once (unless it's hundreds of kilobytes of course)
Philippe Leybaert
A: 

I have been dealing with these issues alot on my current project. It has more to do with the 3G performance and latency then the actual iphone itself. Even with larger amounts of data it would be more efficient to download it all in one hit.

So i would agree with Philippe.

kohlerfc