TL;DR
Facebook built a robust, scalable, and user-friendly real-time data processing ecosystem to handle massive data volumes (hundreds of GB/s) for diverse use cases. Their key decision was targeting "seconds" of latency instead of milliseconds, enabling a persistent message bus that significantly improved fault tolerance, scalability, and ease of use across their Puma, Swift, and Stylus systems.
What Problem Does This Paper Address?
The paper addresses the challenge of processing vast amounts of data in real-time to derive immediate insights for applications like user analytics, mobile app diagnostics, and administrative dashboards. While many companies have built their own real-time systems (e.g., Twitter's Storm, Google's Millwheel), Facebook faced the unique problem of managing hundreds of data pipelines, each with specific requirements for latency, throughput, fault tolerance, scalability, and correctness, all while prioritizing ease of use for their engineers.
Methods
Facebook's approach is built around five key design decisions:
- Language Paradigm: They offer a spectrum from declarative (SQL in Puma) for ease of use, to procedural (C++ in Stylus, Python in Swift) for flexibility and performance. This multi-language approach caters to different team needs and skill sets.
- Data Transfer: Instead of direct message transfer (RPC/message queues) or broker-based systems, Facebook relies on Scribe, a persistent message bus. This choice, while introducing a second of latency, decouples processing nodes, enhancing fault tolerance, scalability, and simplifying debugging.
- Processing Semantics: They provide options for "at-least-once," "at-most-once," and "exactly-once" semantics for both state and output. This allows developers to choose the level of correctness needed, balancing it against performance and complexity.
- State-Saving Mechanism: For stateful processors, they support local persistence (e.g., RocksDB) for faster recovery and remote database persistence for larger states, offering flexibility in fault tolerance strategies.
- Reprocessing: They enable reprocessing of historical data by leveraging their batch processing environment (Hive) and adapting their stream processing systems (Puma, Stylus) to run in this batch context, ensuring consistency and enabling backfilling of metrics.
Datasets
Not discussed in the paper. The paper focuses on the systems and infrastructure rather than specific datasets used for training or evaluation.
Key Insights and Ideas
- "Seconds" is Good Enough: The decision to target seconds of latency, rather than milliseconds, was a pivotal choice. It unlocked the use of a persistent message bus (Scribe), which provided significant benefits in fault tolerance, scalability, and ease of use, without compromising the needs of most Facebook use cases.
- Ease of Use is Paramount: The paper strongly emphasizes that ease of use extends beyond writing code to include testing, debugging, deployment, and monitoring. Providing user-friendly tools and self-service capabilities for these aspects is crucial for widespread adoption and efficient operation of hundreds of pipelines.
- A Spectrum of Correctness: Not all applications require strict ACID guarantees. Offering choices in processing semantics (at-least-once, at-most-once, exactly-once) allows developers to select the appropriate level of correctness, optimizing for performance and complexity where strict guarantees aren't necessary.
- Composability is Key: The ecosystem of Puma, Swift, and Stylus, connected via Scribe, allows for complex Directed Acyclic Graphs (DAGs) where components can be easily swapped, reused, and integrated, fostering rapid development and iteration.
- Hybrid Streaming and Batch: Combining streaming and batch processing is not an "either/or" scenario. Facebook effectively uses both to optimize pipeline completion times and leverage existing infrastructure.
Key Results
- Scalability: The system handles hundreds of Gigabytes per second across hundreds of data pipelines.
- Latency: Targeting "seconds" of latency is sufficient for most use cases.
- Throughput: Stylus achieved nearly 4x the throughput of Swift for a specific processor by optimizing side-effect-free processing between checkpoints.
- Cost Savings: Migrating dashboard queries from Scuba to Puma resulted in approximately 14% of the CPU cost.
- Pipeline Speedup: Converting batch pipelines to hybrid real-time/batch pipelines has sped them up by 10 to 24 hours.
Limitations and Future Work
- Language Paradigm: While they offer multiple languages, they don't currently provide a functional paradigm, though they are exploring Spark Streaming.
- Monitoring and Alerting: While they have processing lag alerts, they aim to provide automatically configured dashboards and alerts for all users in the future.
- Automatic Scaling: They plan to implement automatic scaling for applications.
- Infrastructure Scaling: Future work includes improving dynamic load balancing for stream processing jobs and minimizing recovery time for lagging jobs.
- Runtime Environments: They are considering alternate runtime environments for backfill jobs, evaluating Spark and Flink.
- Bridging Batch and Realtime: A key future goal is to further bridge the gap between real-time and batch processing at Facebook.
Summary updated