Building Mobile-First Infrastructure for Messenger

Visit the post for more.

Jeremy Fein
6 min readintermediate
--
View Original

Overview

The article discusses the transformation of Facebook Messenger's infrastructure to a mobile-first approach, focusing on optimizing data synchronization and reducing data usage. Key improvements include a new sync protocol that decreases non-media data usage by 40% and the introduction of the Iris service to enhance real-time messaging reliability.

What You'll Learn

1

How to implement a push-based snapshot and delta model for real-time messaging applications

2

Why using Thrift can improve data transmission efficiency over JSON

3

How to design a messaging infrastructure that supports real-time updates and long-term storage synchronization

Prerequisites & Requirements

  • Understanding of messaging protocols and data synchronization techniques
  • Familiarity with MySQL and MQTT(optional)

Key Questions Answered

How does the new Messenger sync protocol reduce data usage?
The new Messenger sync protocol reduces non-media data usage by approximately 40% by implementing a push-based snapshot and delta model, which minimizes the need for frequent HTTPS requests and optimizes data transmission.
What is the role of the Iris service in Messenger's infrastructure?
Iris is a totally ordered queue of messaging updates that allows real-time synchronization of messages to the Messenger app and traditional storage. It enables independent rates of updates for the app and storage, improving reliability and performance.
Why did Facebook switch from JSON to Thrift for data transmission?
Facebook switched from JSON to Thrift to reduce payload size on the wire by roughly 50%. Thrift is more efficient than JSON for data transfer, which is crucial for a mobile-first application where bandwidth is limited.
What improvements were observed after the infrastructure changes?
After implementing the new infrastructure, there was a 20% decrease in the number of users experiencing errors when sending messages, indicating improved reliability and performance of the Messenger app.

Key Statistics & Figures

Reduction in non-media data usage
40%
Achieved through the new Messenger sync protocol.
Decrease in message sending errors
20%
Observed after the implementation of the new infrastructure.
Payload size reduction
50%
Reduction achieved by switching from JSON to Thrift for data transmission.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Data Serialization
Thrift
Used to improve data transmission efficiency over JSON.
Database
Mysql
Utilized for building the queue storage and ensuring durability across multiple servers.
Communication Protocol
Mqtt
Employed for pushing delta updates to the Messenger app.

Key Actionable Insights

1
Implement a push-based model for real-time applications to enhance user experience.
By reducing the reliance on pull-based data fetching, applications can deliver updates more efficiently, leading to lower latency and improved user satisfaction.
2
Consider using Thrift instead of JSON for data transmission in bandwidth-sensitive applications.
Thrift's efficiency can significantly reduce data payload sizes, which is especially beneficial for mobile applications operating on limited data plans.
3
Design messaging systems with a focus on real-time updates and parallel processing.
This approach ensures that message delivery is not hindered by storage write latencies, maintaining a seamless user experience even during outages.

Common Pitfalls

1
Relying on pull-based data fetching can lead to increased latency and a poor user experience.
This happens because pull-based models require frequent requests to the server, which can be slow and inefficient, especially on mobile networks with limited bandwidth.

Related Concepts

Data Synchronization Techniques
Real-time Messaging Systems
Mobile-first Application Design