Scaling the Messages Application Back End

Visit the post for more.

Prashant Malik
7 min readintermediate
--
View Original

Overview

The article discusses the architecture and infrastructure developed by Facebook to scale the Messages application back end, integrating various communication channels such as email, SMS, and Facebook Chat. It highlights the challenges of scalability, real-time operation, and high availability, and explains the role of application servers and distributed logic in overcoming these challenges.

What You'll Learn

1

How to design a scalable architecture for messaging applications

2

Why using ZooKeeper is essential for managing distributed systems

3

How to implement a discovery service for user-to-cell mappings

Prerequisites & Requirements

  • Understanding of distributed systems and messaging protocols
  • Familiarity with ZooKeeper and HBase(optional)

Key Questions Answered

What are the main components of the Messages application back end?
The main components include application servers, a distributed logic layer, a metadata store using HBase, and a discovery service. Each application server handles user queries, while the distributed logic manages user data across different cells, ensuring scalability and high availability.
How does the discovery service work in the Messages application?
The discovery service maps users to specific cells, allowing clients to find the correct application server for their requests. It needs to be highly available and performant to support the large number of users accessing the system.
What advantages do cells provide in the architecture?
Cells help scale the system incrementally, limit failure scenarios, facilitate easy upgrades, and allow for flexibility in hosting across different data centers. They also ensure that metadata store failures impact only a subset of users.
What role does ZooKeeper play in the Messages application back end?
ZooKeeper is used for sharding application servers and managing failover. It provides a highly available repository for service discovery, allowing application servers to register and manage user load effectively.

Technologies & Tools

Backend
Zookeeper
Used for sharding application servers and managing failover.
Database
Hbase
Serves as the metadata store for user data.
Storage
Haystack
Used for storing parsed email messages and attachments.

Key Actionable Insights

1
Implementing a distributed architecture using cells can significantly improve scalability and reliability.
By dividing the user base into cells, you can manage load more effectively and reduce the impact of failures, making your application more resilient.
2
Utilizing ZooKeeper for service discovery and management can streamline operations in distributed systems.
ZooKeeper allows for efficient management of application server states, which is crucial for maintaining high availability and performance in large-scale applications.
3
Incorporating a dedicated metadata store like HBase can enhance data management and retrieval.
HBase provides a robust solution for storing user metadata, ensuring that data is easily accessible and can be backed up efficiently.

Common Pitfalls

1
Failing to implement a robust discovery service can lead to performance bottlenecks.
Without a reliable discovery mechanism, clients may struggle to find the correct application server, resulting in increased latency and potential service disruptions.
2
Neglecting to monitor the health of application servers can result in unnoticed failures.
Regular monitoring is essential to ensure that application servers are functioning correctly and to quickly address any issues that arise.