Apache Storm
- Problem solved: process endless streams (tweets, clicks) continuously, within milliseconds and with fault tolerance, where Hadoop could only work in batch.
- Era: designed at BackType in late 2010, open sourced by Twitter on September 19, 2011, Apache Incubator on September 18, 2013, top-level project on September 17, 2014. Storm 2.0, rewritten in Java, in May 2019.
- Created by: Nathan Marz, at BackType, a startup acquired by Twitter in July 2011.
- Category: distributed stream processing engine.
Historical context
In the early 2010s, Hadoop has made large-scale processing accessible, but in batch: a job reads data at rest and finishes. At BackType, a startup measuring the impact of businesses on social media, Nathan Marz has to process the Twitter stream in real time. The team writes the Twitter firehose into message queues, read by Python workers, which feed other queues and other workers. Marz finds the approach "brittle": queues and workers must be kept alive, and most of the code is about routing and serializing messages.
In December 2010, Marz comes up with three abstractions: spouts (stream sources), bolts (processing steps) and the topology that connects them. A few weeks later, he finds an algorithm based on random numbers and XOR to track each message with "about 20 bytes". It takes him five months to write the first version: APIs in Java, implementation in Clojure. In May 2011, Twitter is in talks to acquire BackType; Marz publishes a post presenting Storm as "the Hadoop of realtime", partly to raise the valuation. BackType joins Twitter in July 2011.
On September 19, 2011, Marz open sources Storm at the Strange Loop conference, with "about 12,000 words" of documentation; the project reaches the top of Hacker News. Less than a month later, he formalizes the Lambda architecture: an exact batch layer and a fast real-time layer. In January 2012, a survey counts 10 companies in production and 30 experimenting. Storm@Twitter (SIGMOD 2014) describes hundreds of topologies on hundreds of servers.
Marz leaves Twitter in March 2013. Andy Feng, at Yahoo, pushes for a move to the Apache Software Foundation: Storm enters the incubator on September 18, 2013 and becomes a top-level project on September 17, 2014, "just short of three years after being open-sourced". Meanwhile, Twitter forked its version in October 2013 and replaces it in 2015 with Heron, compatible with the Storm API. Storm 2.0 (May 2019) drops Clojure for a core "in pure Java".
Key idea
A MapReduce job finishes; a Storm topology "processes messages forever". The stream is "an unbounded sequence of tuples", and the program is a graph: spouts emit tuples, bolts transform them and emit new ones. Storm spreads this graph over a cluster, restarts what fails and guarantees that every tuple coming from a spout is processed at least once, with no intermediate queue between steps.
How it works
- Nimbus: the master daemon, "similar to Hadoop's JobTracker", distributes code and assigns tasks.
- Supervisor: one daemon per machine, which starts and watches workers.
- ZooKeeper: all coordination goes through it and state is kept there;
Nimbus and the Supervisors are "fail-fast and stateless", you can
kill -9them and they come back "like nothing happened". - No intermediate queue: tuples go straight from one thread to another (through ZeroMQ in 2011, Netty later), with no central router.
- Stream groupings: they decide which bolt receives which tuple. Shuffle spreads randomly, fields sends the same key to the same bolt, all, global and local complete the list.
- Acker and XOR: each tuple gets a random 64-bit id. An "acker" bolt XORs the ids that are emitted then acknowledged; when the result is back to zero, the whole tuple tree is processed. Otherwise Storm replays the tuple from the spout.
- Trident: a "micro-batching API" added later to provide exactly-once.
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("sentences", new SentenceSpout(), 2);
builder.setBolt("split", new SplitSentence(), 4)
.shuffleGrouping("sentences"); // random
builder.setBolt("count", new WordCount(), 4)
.fieldsGrouping("split", new Fields("word")); // same word, same bolt
storm jar all-my-code.jar backtype.storm.MyTopology arg1 arg2
By the numbers
| Figure | Context | Source |
|---|---|---|
| 20 bytes | Memory to track a spout tuple and its whole tree (2010-2011) | Nathan Marz blog 2014 |
| 5 months | Development of the first version at BackType (2011) | Nathan Marz blog 2014 |
| 12,000 words | Documentation published on open source day (September 2011) | Nathan Marz blog 2014 |
| 10, 15, 30 | Companies in production, planning, and experimenting (January 2012 survey) | Nathan Marz blog 2014 |
| 1 million | 100-byte messages processed per second per node (benchmark, 2014) | ASF announcement 2014 |
| About 1 ms | 99th percentile latency at Twitter (2014) | Storm@Twitter paper |
| 10 to 14x | Heron throughput compared to Storm at Twitter (2015) | Twitter blog 2015 |
Milestones
- December 2010: Nathan Marz designs spouts, bolts and topologies at BackType; the XOR algorithm follows a few weeks later.
- July 2011: BackType joins Twitter.
- August 4, 2011: Twitter presents Storm on its engineering blog.
- September 19, 2011: open sourced at the Strange Loop conference.
- October 13, 2011: Marz describes the Lambda architecture ("How to beat the CAP theorem").
- September 18, 2013: enters the Apache Incubator, on Yahoo's initiative.
- February 22, 2014: release 0.9.1-incubating.
- September 17, 2014: Apache top-level project (announced on September 29).
- June 2015: Twitter presents Heron, its compatible replacement.
- May 30, 2019: Storm 2.0.0, core rewritten in Java.
Did you know?
- A post for the valuation. Marz says he wrote the "Hadoop of realtime" post during the negotiations with Twitter to "raise our valuation".
- An algorithm, a failed date. Marz considers the XOR algorithm "one of the best algorithms I ever developed". The day he found it, he had a date, and admits: "I did not do well with the girl."
- A licensing issue. To enter the ASF, Storm had to replace ZeroMQ, whose licence was incompatible, with Netty.
- Clojure, a brake on adoption. Storm 2.0 notes that Clojure was "often cited as a barrier for entry" and rewrites the core in Java.
Strengths and limitations
| Strengths | Limitations |
|---|---|
| Millisecond-level latency (p99 close to 1 ms at Twitter, 2014) | Basic guarantee is at-least-once; exactly-once requires Trident micro-batches |
| Simple model: spouts, bolts, groupings | ZooKeeper limited a cluster to about 300 workers, then 1,200 after optimization |
| Cheap message tracking thanks to XOR | Throughput 10 to 14 times lower than Heron according to Twitter (2015) |
| Broad adoption: more than 60 companies in 2014 (Yahoo, Groupon, Alibaba...) | Clojure core until 2019, a "barrier for entry" |
What came next
- The Lambda architecture, then Jay Kreps's critique of it (Kappa, 2014), which proposes to replay everything from Kafka: see the timeline.
- At Twitter, the KafkaSpout, which reads Kafka topics, accounted for 67% of Storm's ZooKeeper writes (2014).
- Flink brings distributed state and exactly-once without micro-batches.
- Beam unifies batch and streaming in one model, in answer to the double maintenance of Lambda.
- Heron, at Twitter, keeps the Storm API with a new engine.
Sources
raw-data/apache/storm/storm.mdraw-data/chronologie/jalons-sources.md- http://nathanmarz.com/blog/history-of-apache-storm-and-lessons-learned.html
- https://web.archive.org/web/2011/https://blog.twitter.com/2011/storm-coming-more-details-and-plans-release
- https://incubator.apache.org/projects/storm.html
- https://news.apache.org/foundation/entry/the_apache_software_foundation_announces64
- Toshniwal et al., "Storm@Twitter", SIGMOD 2014, https://dl.acm.org/doi/10.1145/2588555.2595641
- https://web.archive.org/web/2015/https://blog.twitter.com/2015/flying-faster-with-twitter-heron
- https://storm.apache.org/2019/05/30/storm200-released.html
- http://nathanmarz.com/blog/how-to-beat-the-cap-theorem.html
- https://news.ycombinator.com/item?id=3014039
- The Storm@Twitter paper says "Twitter open-sourced Storm in 2012": contradicted by every other source (September 2011), probably an error in the paper.
- Exact date of Twitter's acquisition of BackType: July 2011 according to Marz, already acquired on August 4, 2011 according to the Twitter blog; precise day not found.
- Release date of Trident (Storm 0.8): to read in an official source.