Abstract
Twitter’s Heron is a second-generation real-time streaming engine designed to replace Apache Storm. By transitioning from a thread-based to a process-based architecture, Heron achieves 2-5x better efficiency, easier debugging through strict task isolation, and more predictable performance via a novel spout-based back-pressure mechanism. This paper details the architectural shifts required to handle tens of billions of events per hour at Twitter scale.
Introduction
As Twitter grew to generate tens of billions of events per hour, their reliance on Apache Storm for real-time analytics (like trending hashtags and ad-modeling) hit a ceiling. Storm’s architecture—where multiple tasks shared a single JVM thread pool—made it a nightmare to debug and profile. A single "heavy" task could starve others in the same process, and "noisy neighbor" issues in shared clusters led to unpredictable performance.
The authors identify three main gaps in existing systems:
- Lack of Isolation: Difficulty in identifying which specific task is causing a bottleneck or crashing.
- Resource Management: Inability to reserve specific CPU/RAM for topologies, leading to contention.
- Inefficient Back Pressure: Standard TCP-based back pressure often led to "throughput-to-zero" scenarios due to data multiplexing across shared buffers.
System Architecture
Heron introduces a "process-per-task" architecture. Instead of running multiple spouts (data sources) and bolts (processors) as threads in one worker, each task runs as a dedicated Heron Instance.
Key architectural components include:
- Topology Master: A single process that manages the state of the entire Directed Acyclic Graph (DAG).
- Stream Manager: A "traffic cop" that routes data between instances. It uses a custom spout-based back pressure mechanism: when a bolt slows down, the system explicitly signals the spouts to stop consuming from the source rather than letting internal buffers overflow.
- Metrics Manager: A dedicated service for collecting and exporting system-wide performance data.
- Resource Reservation: Heron leverages Linux cgroups to enforce strict resource limits, ensuring that a spike in one topology doesn't crash other critical services sharing the same hardware.
Logical and Physical Plans
In Heron, a logical plan defines the data flow between spouts and bolts. This is then mapped to a physical plan where each component is instantiated multiple times to handle the required throughput. By giving every task its own process, developers can use standard tools like top, jstack, or YourKit on a specific instance. Logs are also isolated, making it trivial to find the "offending" task.
Key Insights and Results
- The Multiplexing Trap: The authors discovered that leveraging standard TCP back pressure is dangerous in streaming. Because multiple logical streams share one physical TCP connection, slowing down one "slow" bolt can inadvertently block "fast" bolts sharing that connection. Heron's application-level signaling to the spouts decouples these dependencies.
- Storm Compatibility: To ensure adoption, Heron was built to be API-compatible with Storm. This allowed Twitter to migrate massive production workloads with zero code changes.
- Performance: Heron is 2-5x more efficient than Storm in terms of resource utilization. It successfully handles tens of billions of events per hour across hundreds of development and production topologies.
- Operational Stability: The system has been in production at Twitter for over two years, handling massive spikes during events like the Super Bowl and the Oscars without manual intervention.
Limitations and Future Work
While Heron represents a major step forward, several challenges remain. Currently, users must manually estimate resource needs (CPU/RAM). Future work aims to automate this via linear regression and sampling. Additionally, Heron currently supports "at-most-once" and "at-least-once" processing; achieving "exactly-once" semantics remains a challenge requiring distributed partitionable state. Finally, the authors aim to move toward a higher-level SQL-like query paradigm to improve developer productivity.
Summary updated