How Facebook Designed its Android App for Emerging Markets
In order to fulfill its vision of connecting the Earth, Facebook has designed its Facebook Lite app for Android to make it optimized for use in emerging markets, Facebook engineer Gautam Roy explained.
While true that mobile technology has been recently booming in emerging markets, the differences between emerging and developed countries are huge when it comes to the mobile space. In particular, 3G and 4G mobile networks are not widely available in emerging countries, and even when a 3G connection is there, it may only work intermittently. Furthermore, a 3G connection is in many cases simply too expensive for most people. On the other hand, as Gautam Roy wrote, 2G networks connect up to 96% of people globally and are used by over half the world’s population. This context thus defined Facebook goals, which were namely:
- small app footprint (below 1MB APK size);
- low data usage and 2G network support;
- older, 2009 class device support.
The main architectural decision that Facebook engineers took was to use a proxy server, as shown in the picture below, and to implement the Android app as a thin client.
This architecture was designed so the server does the heavy lifting, says Roy, by fetching data from Facebook backend services and packaging them for the client to use. Thus app features are mostly implemented by the proxy server. The client app itself is designed as a kind of virtual machine that provides access to OS resources such as camera, SQL lite engine, and the UI engine. Additionally, the client app is relying on a local cache to avoid having to request the same items multiple times. Interestingly, instead of using HTTPS, Facebook engineers devised their own custom message protocol over TLS in order to further reduce data usage and shrink the time required to establish a secure connection.
Thanks to these design choices, concludes Roy, Facebook engineers could achieve best-in-class performance on tasks like login, start-up, pull-to-refresh, and image-loading times and to ensure correct behaviour even on low-performance and intermittent networks.