How did engineers make Facebook Messenger more efficient?


As Facebook unbundled messaging from the main mobile app, the company started making major improvements to its standalone Facebook Messenger app. A blog post by Facebook engineers Jeremy Fein and Jason Jenks shows how the social network made Messenger more efficient.

Fein and Jenks wrote that Messenger has decreased non-media data usage by 40 percent (developing a new service called Iris to power it). Users have taken note of improvements to Messenger, as there has been a 20 percent dip in the number of people who experience errors when trying to send a message.

Fein and Jenks wrote of what it took to revamp the Facebook Messenger app:

Messaging data has traditionally been stored on spinning disks. In the pull-based model, we’d write to disk before sending a trigger to Messenger to read from disk. Thus, this giant storage tier would serve real-time message data as well as the full conversation history. One large storage tier doesn’t scale well to synchronize recent messages to the app in real time. So in order to support this new, faster sync protocol and maintain consistency between the Messenger app and long-term storage, we need to be able to stream the same sequence of updates in real time to Messenger and to the storage tier in parallel on a per user basis.

Iris is a totally ordered queue of messaging updates (new messages, state change for messages read, etc.) with separate pointers into the queue indicating the last update sent to your Messenger app and the traditional storage tier. When successfully sending a message to disk or to your phone, the corresponding pointer is advanced. When your phone is offline, or there is a disk outage, the pointer stays in place while new messages can still be enqueued and other pointers advanced. As a result, long disk write latencies don’t hinder Messenger’s real-time communication, and we can keep Messenger and the traditional storage tier in sync at independent rates.

They also included a diagram showing the flow of storing messages:

10574692_663814820398517_431290582_nReaders: Have you noticed a faster Messenger experience?