How understanding mobile networks will improve your app’s performance

On June 16, 2011

You’ve built web apps and mobile apps (and probably even mobile web apps), but have you ever wondered how the technology differences between the traditional web and mobile web are affecting how your app runs?

The 2 biggest issues that affect mobile users today are the network (how the data gets to their phone), and battery life.   Simple optimizations to your application can improve both of these issues noticeably for your users.

Background:  Latency
Mobile networks have limited bandwidth and high latency compared to WiFi and broadband.   Mobile networks take 100-1000x LONGER to initiate a TCP connection over traditional connections.  The first connection to the internet requires phone radio-tower-internet connections, which can take up to 2 seconds!  This is something that you (and your users!) notice.

Because of this high latency, mobile operators have invoked a state machine to all connections.

Wireless State Machine
What’s a state machine?  Since that first connection took 2 seconds to establish, the network keeps the radio connection between the device and network open in a high power/high bandwidth state for several seconds after the last packet is sent (in case more data comes in).  If a new TCP connection is established in this timeframe, it only takes 100-200ms to establish (still not as fast as broadband or WiFi, but still noticeably faster than 2s).  After a period of inactivity, the network drops to a lower bandwidth/energy shared channel, and if no data comes in – eventually the radio connection times out and is closed.

Basically the state machine keeps the radio network open for a set period of time whenever it is opened in an attempt to ‘hide’ the connection latency in frequent connections.  The timers in the state machine run a delicate balance to keep connections open and flowing – but also not draining the battery excessively.

So what do I do?

When architecting your application, you should consider the state machine.  Every connection your application makes adds latency to your customers and drains their battery.  Think of the battery life as a valuable resource for your customers – you want to minimize your impact.  By reducing the number of connections and maximizing the use of each connection, your app will appear faster to users, and also drain the battery less.

In future posts, I will detail several best practices for application optimization that we have discovered while working with the state machine.  For more details on the wireless state machine and how to make your application more energy efficient, you can read an article recently published by AT&T Research Labs.