Heron is a general-purpose stream processing engine designed for speedy performance, low latency, isolation, reliability, and ease of use for developers and administrators alike. Heron was open sourced by Twitter in May 2016.
The sections below:
- clarify the distinction between Heron and Apache Storm
- describe Heron’s basic system architecture
- explain the role of major components of Heron’s architecture
- provide an overview of what happens when submit a topology
More information can be found in the Heron Topologies document.
Relationship with Apache Storm
Apache Storm is a stream processing system originally open sourced by Twitter in 2011. Heron, also developed at Twitter, was created to overcome many of the shortcomings that Storm exhibited when run in production at Twitter scale.
|Resource isolation||Heron uses process-based isolation both between topologies and between containers within topologies, which is more reliable and easier to monitor and debug than Storm’s model, which involves shared communication threads in the same JVM|
|Resource efficiency||Storm requires scheduler resources to be provisioned up front, which can lead to over-provisioning. Heron avoids this problem by using cluster resources on demand.|
|Throughput||For a variety of architectural reasons, Heron has consistently been shown to provide much higher throughput and much lower latency than Storm|
Currently, Heron is compatible with topologies written using:
Heron was initially developed at Twitter with a few main goals in mind:
- Providing blazing-fast performance, reliability, and easy troubleshooting by leveraging a process-based computing model and full topology isolation.
- Retaining full compatibility with Storm’s data model and topology API.
For a more in-depth discussion of Heron and Storm, see the Twitter Heron: Stream Processing at Scale paper.
Heron thus enables you to achieve major gains along a variety of axes—throughput, latency, reliability—without needing to sacrifice engineering resources.
Heron Design Goals
For a description of the core goals of Heron as well as the principles that have guided its development, see Heron Design Goals.
Basic system architecture
In a Heron cluster
From an architectural standpoint, Heron was built as an interconnected set of modular components.
The following core components of Heron topologies are discussed in depth in the sections below:
The Topology Master (TM) manages a topology throughout its entire lifecycle,
from the time it’s submitted until it’s ultimately killed. When
a topology it starts a single TM and multiple containers.
The TM creates an ephemeral ZooKeeper node to
ensure that there’s only one TM for the topology and that the TM is easily
discoverable by any process in the topology. The TM also constructs the physical
plan for a topology which it relays to different
Topology Master Configuration
Each Heron topology consists of multiple containers, each of which houses multiple Heron Instances, a Stream Manager, and a Metrics Manager. Containers communicate with the topology’s TM to ensure that the topology forms a fully connected graph.
For an illustration, see the figure in the Topology Master section above.
The Stream Manager (SM) manages the routing of tuples between topology components. Each Heron Instance in a topology connects to its local SM, while all of the SMs in a given topology connect to one another to form a network. Below is a visual illustration of a network of SMs:
In addition to being a routing engine for data streams, SMs are responsible for propagating back pressure within the topology when necessary. Below is an illustration of back pressure:
In the diagram above, assume that bolt B3 (in container A) receives all of its inputs from spout S1. B3 is running more slowly than other components. In response, the SM for container A will refuse input from the SMs in containers C and D, which will lead to the socket buffers in those containers filling up, which could lead to throughput collapse.
In a situation like this, Heron’s back pressure mechanism will kick in. The SM in container A will send a message to all the other SMs. In response, the other SMs will examine the container’s physical plan and cut off inputs from spouts that feed bolt B3 (in this case spout S1).
Once the lagging bolt (B3) begins functioning normally, the SM in container A will notify the other SMs and stream routing within the topology will return to normal.
Stream Manger Configuration
Currently, Heron only supports Java, so all HIs are JVM processes, but this will change in the future.
Heron Instance Configuration
Each topology runs a Metrics Manager (MM) that collects and exports metrics from all components in a container. It then routes those metrics to both the Topology Master and to external collectors, such as Scribe, Graphite, or analogous systems.
You can adapt Heron to support additional systems by implementing your own custom metrics sink.
All of the components listed in the sections above can be found in each topology. The components listed below are cluster-level components that function outside of particular topologies.
Heron has a CLI tool called
heron that is used to manage topologies.
Documentation can be found in Managing
Heron API server
When running Heron locally, you won’t need to deploy or configure the Heron API server.
The Heron Tracker (or just Tracker) is a centralized gateway for cluster-wide information about topologies, including which topologies are running, being launched, being killed, etc. It relies on the same ZooKeeper nodes as the topologies in the cluster and exposes that information through a JSON REST API. The Tracker can be run within your Heron cluster (on the same set of machines managed by your Heron scheduler) or outside of it.
Instructions on running the tracker including JSON API docs can be found in Heron Tracker.
Heron UI is a rich visual interface that you can use to interact with topologies. Through Heron UI you can see color-coded visual representations of the logical and physical plan of each topology in your cluster.
For more information, see the Heron UI document.
The diagram below illustrates what happens when you submit a Heron topology:
|Client||When a topology is submitted using the
|Heron API server||When the Heron API server has been notified that a topology is being submitted, it does two things. First, it uploads the topology artifacts (a JAR for Java or a PEX for Python, plus a few other files) to a storage service; Heron supports multiple uploaders for a variety of storage systems, such as Amazon S3, HDFS, and the local filesystem.|
|Heron scheduler||When the Heron CLI (client) submits a topology to the Heron API server, the API server notifies the Heron scheduler and also provides the scheduler with the topology’s logical plan, physical plan, and some other artifacts. The scheduler, be it Mesos, Aurora, the local filesystem, or something else, then deploys the topology using containers.|
|Storage||When the topology is deployed to containers by the scheduler, the code running in those containers then downloads the remaining necessary topology artifacts (essentially the code that will run in those containers) from the storage system.|
<!– * Shared Services
When the main scheduler (`com.twitter.heron.scheduler.SchedulerMain`) is invoked by the launcher, it fetches the submitted topology artifact from the topology storage, initializes the State Manager, and prepares a physical plan that specifies how multiple instances should be packed into containers. Then, it starts the specified scheduler, such as `com.twitter.heron.scheduler.local.LocalScheduler`, which invokes the `heron-executor` for each container.
heron-executorprocess is started for each container and is responsible for executing the Topology Master or Heron Instances (Bolt/Spout) that are assigned to the container. Note that the Topology Master is always executed on container 0. When
heron-executorexecutes normal Heron Instances (i.e. except for container 0), it first prepares the Stream Manager and the Metrics Manager before starting
com.twitter.heron.instance.HeronInstancefor each instance that is assigned to the container.
Heron Instance has two threads: the gateway thread and the slave thread. The gateway thread is mainly responsible for communicating with the Stream Manager and the Metrics Manager using
MetricsManagerClientrespectively, as well as sending/receiving tuples to/from the slave thread. On the other hand, the slave thread runs either spout or bolt of the topology based on the physical plan.
When a new Heron Instance is started, its
StreamManagerClientestablishes a connection and registers itself with the stream manager. After the successful registration, the gateway thread sends its physical plan to the slave thread, which then executes the assigned instance accordingly.
Heron is primarily written in Java, C++, and Python.
A detailed guide to the Heron codebase can be found here.