4

Uploads from my app are too slow, and I'd like to gather some real data as to where the time is being spent.

By way of example, here are a few stages a request goes through:

  1. Initial radio connection (significant source of latency in EDGE)
  2. DNS lookup (if not cached)
  3. SSL/TLS handshake.
  4. HTTP request upload, including data.
  5. Server processing time.
  6. HTTP response download.

I can address most of these (e.g. by powering up the radio earlier via a dummy request, establishing a dummy HTTP 1.1 connection, etc.), but I'd like to know which ones are actually contributing to network slowness, on actual devices, with my actual data, using actual cell towers.

If I were using WiFi, I could track a bunch of these with Wireshark and some synchronized clocks, but I need cellular data.

Is there any good way to get this detailed breakdown, short of having to (gak!) use very low level socket functions to reproduce my vanilla http request?

Josh Bleecher Snyder
  • 8,262
  • 3
  • 35
  • 37
  • when you say slow how slow we talking? – John Boker Dec 22 '10 at 00:33
  • On the order of 3-10s. But for the particular purposes I'm putting it to, I'd really like to cut that down to 1-3s. Serverside processing is a very small proportion of that. I can make some trade-offs between startup time and upload size (e.g. by doing more expensive, aggressive data compression). I did some back of the envelopes based on documented EDGE/3G latency and bandwidths, but I'd rather make such decisions based off real, observed data. – Josh Bleecher Snyder Dec 22 '10 at 00:38

2 Answers2

0

An easy solution to this would be once the application get's fired, make a Long Polling connection with the server (you can choose when this connection need's to establish prior hand, and when to disconnect), but that is a kind of a hack if you want to avoid all the sniffing of packets with less api exposure iOS provides.

topgun
  • 2,463
  • 8
  • 31
  • 46
0

Ok, the method I would use is not easy, but it does work. Maybe you're already tried this, but bear with me.

I get a time-stamped log of the sending time of each message, the time each message is received, and the time it is acted upon. If this involves multiple processes or threads, I have each one generate a log, and then merge them into a common timeline.

Then I plot out the timeline. (A tool would be nice, but I did it by hand.) What I look for is things like 1) messages re-transmitted due to timeouts, 2) delays between the time a message is received and the time it's acted upon.

Usually, this identifies problems that I can fix in the code I can control. This improves things, but then I do it all over again, because chances are pretty good that I missed something the last time.

The result was that a system of asynchronous message-passing can be made to run quite fast, once preventable sources of delay have been eliminated.

There is a tendency in posting questions about performance to look for magic fixes to improve the situation. But, the real magic fix is to refine your diagnostic technique so it tells you what to fix, because it will be different from anyone else's.

Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
  • I'm not sure I entirely follow how to apply your suggestion to my question, but...the problem is that I don't have much visibility into the behind-the-scenes once I initiate an https request in iOS. If I did, I would indeed log everything, pay attention to the times, etc. The problem is that I'm trying to figure out the breakdown of what happens in the parts I can't see. And I'm definitely not looking for magic fixes -- I'm looking for data! :) – Josh Bleecher Snyder Dec 22 '10 at 03:05
  • @Josh: That makes it tough. There used to be a gadget that could monitor traffic over a network connection. That's where I would dig. It's hard when all you can really do is guess and try things. – Mike Dunlavey Dec 22 '10 at 03:11
  • yeah...if it were wifi, I'd just route traffic over an ad hoc connection on my computer and sniff the packets with WireShark. I wonder if it would be possible to do something like that with a femptocell plugged into a router I control... – Josh Bleecher Snyder Dec 22 '10 at 03:22
  • @JoshBleecherSnyder: were you ever able to find a good solution to this? I am interested in this exact diagnostic data as well... – bradleyrzeller Nov 23 '13 at 01:19