Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News How Facebook Improved their iOS App Start Time

How Facebook Improved their iOS App Start Time

This item in japanese


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