BT

How Facebook Improved their iOS App Start Time

| by Sergio De Simone Follow 21 Followers on Dec 06, 2015. Estimated reading time: 2 minutes |

 

Facebook engineer Natansh Verma explained how they managed to reduce the launch time of the Facebook app for iOS and shave a few seconds off.

According to Verma, the first step when optimizing launch time is defining a stable metrics. In their case, they found that the moment when the feed had finished loading was a good reference of when the launch process could be considered finished. Additionally, they took the decision to optimize the so-called “cold start”, i.e. the time it takes to launch an app when it is not running at all, which offers more areas to tweak than warm start, where the app is already running in the background and some event brings it to the fore.

Once instrumented the app, Facebook engineers found out that the initialization phase leading to the first feed request being sent out was taking too long. This was tackled in two different ways:

  • by analyzing and removing unnecessary dependencies on the path to the first network request, which only required having valid authentication token and feed cursors available;
  • by working around the time it takes to set up a secure TCP connection, which requires 3 round-trips to the server, thanks to a technique they called UDP priming. In short, the app sends out an encrypted UDP packet with the feed request to the server. This will provide a hint to the server that a proper TCP request is coming, so it can pre-fetch and cache data in advance.

After ensuring the initial feed request went out as early as possible, Facebook engineers identified another area of improvement in the story-fetching strategy. So, they moved from providing stories in two batches of three and seven stories to a more stream-like model where they provided stories in 1+1+X batches.

Interestingly, reducing the time it took for the first story to come back had the effect of highlighting some resource contention among a few app services that slowed down the rendering engine. This particular problem was solved by introducing a queueing mechanism so all those services could kick in after app start completed.

Summing all up, Verma says, those optimizations provided a multi-second improvement in their app’s launch time.

Mobile apps’ launch time is an important factor of user experience, and Apple used to suggest that it should be as short as possible to prevent users from feeling less inclined to use them.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT