Apache Druid
- Problem solved: aggregate and filter billions of events, both just ingested and historical, in under a second, for interactive dashboards used by hundreds of people at the same time.
- Era: specification on February 7, 2011, in production on April 4, 2011 at Metamarkets, code released in October 2012, Apache 2.0 licence in February 2015, Apache Incubator on February 28, 2018, Apache top-level project on December 18, 2019.
- Category: real-time analytical database (OLAP, column-oriented).
- Created by: Eric Tschetter, at Metamarkets (an advertising analytics start-up in San Francisco).
Historical context
In the twelve months before April 2011, Metamarkets wants to give its advertising customers a console to explore impression logs while freely filtering on dozens of dimensions. Volumes reach "hundreds of billions of events per month". The team tries relational databases (Greenplum, InfoBright, MySQL) then NoSQL (HBase), without success.
The numbers behind the failure speak for themselves. On Greenplum, a plain scan of 33 million rows takes 3 seconds. With HBase, the team pre-computes every possible aggregation: with 11 dimensions, the computation does not finish within 24 hours; after limiting itself to combinations of 5 dimensions and moving to 14 dimensions, it still takes 9 hours on 25 machines. A colleague's remark unlocks everything: "Dude, I can store that in memory".
Eric Tschetter, Metamarkets' first employee who came from LinkedIn, sends a 553-word email laying out Druid's architecture ("the spec") on February 7, 2011. Eight weeks later, on April 4, 2011, the first Druid service replaces the HBase cluster. On April 30, 2011, the company blog introduces Druid: "So instead we did something crazy: we rolled our own database".
In October 2012, Metamarkets releases the code at an O'Reilly Strata conference, first under the GPL licence [S], then under Apache 2.0 in February 2015 to grow a community. The SIGMOD 2014 paper describes the architecture. The project enters the Apache Incubator on February 28, 2018 and becomes a top-level project on December 18, 2019. In between, Metamarkets was acquired by Snap in 2017.
Key idea
To answer fast, you must neither pre-compute everything (combinatorial explosion) nor reread everything for each query. Druid keeps data in columns, compressed and indexed, split into time slices, and spreads it over many nodes that scan it in parallel, in memory when possible. Time structures everything: each segment covers a given period.
Another intuition: separate fresh data (still being ingested) from historical data (frozen). Fresh events are "immediately available for querying" according to the 2014 paper; they are then handed off in batches as immutable segments, easy to replicate and move.
How it works
- Segments: a table (a datasource) is split into segments, each covering a period of time and typically holding 5 to 10 million rows. Segments are immutable.
- Column storage: dictionary encoding for strings, LZF compression, and bitmap indexes (Concise format) for fast filtering. On a test dataset in the paper, Concise bitmaps are about 42% smaller than integer arrays.
- Services (current architecture): the Coordinator manages segment availability, the Overlord assigns ingestion tasks, the Broker receives queries, the Router routes requests, Historical services serve stored data, MiddleManager and Peon (or the Indexer) ingest.
- External dependencies: a shared deep storage (S3, HDFS...) keeps a copy of every segment, a metadata database (MySQL, PostgreSQL) and ZooKeeper for coordination.
- Queries: native JSON API and SQL, planned by Apache Calcite.
- Sources: Kafka, Hadoop and Iceberg; Avro, ORC or Parquet formats.
-- impressions per hour and per publisher over the last 24 hours
SELECT FLOOR(__time TO HOUR) AS hour_bucket, publisher, SUM(impressions) AS total
FROM ad_events
WHERE __time >= CURRENT_TIMESTAMP - INTERVAL '1' DAY
GROUP BY 1, 2
ORDER BY total DESC
By the numbers
| Figure | Context | Source |
|---|---|---|
| 1 billion rows in 950 ms | Internal benchmark on 40 m2.2xlarge instances (April 2011) | Druid blog 2011 |
| 33 million rows per second per core | Scan speed announced at the code release (October 2012) | Druid blog 2012 |
| 500 MB/s, i.e. 150,000 events/s | Ingestion of one of the largest production clusters (2014) | SIGMOD 2014 paper |
| 50 billion rows, 10.5 TB of RAM | "Hot" tier of Metamarkets' production cluster, 672 cores (2014) | SIGMOD 2014 paper |
| About 550 ms | Average production latency; 90% of queries under 1 s (2014) | SIGMOD 2014 paper |
| Over 100 trillion | Events processed by the original cluster over ten years (May 2021) | Michael Driscoll, Rill |
| 553 words | Length of Eric Tschetter's "the spec" email (February 2011) | Michael Driscoll, Rill |
Milestones
- February 7, 2011: Eric Tschetter sends the Druid specification.
- April 4, 2011: Druid replaces Metamarkets' HBase cluster in production.
- April 30, 2011: public post "Introducing Druid: Real-Time Analytics at a Billion Rows Per Second".
- October 24, 2012: code released, presented at the Strata conference.
- 2014: paper "Druid: A Real-time Analytical Data Store" at SIGMOD.
- February 20, 2015: move to the Apache 2.0 licence.
- 2017: Snap acquires Metamarkets.
- February 28, 2018: enters the Apache Incubator; first incubating release (0.13.0) on December 12, 2018.
- December 18, 2019: Druid becomes an Apache top-level project, chaired by Gian Merlino.
- February 9, 2026: Druid 36.0.0 is released.
Did you know?
- A role-playing game name: "The name Druid comes from the Druid class in many role-playing games: it is a shape-shifter", explains the 2014 paper, because the system takes several forms depending on each node's role.
- A decisive sentence: looking at a 500,000-row dataset, someone said "Dude, I can store that in memory". This is the origin of the choice of distributed in-memory storage.
- Zero downtime: "Over the last two years, we have never taken downtime in our Druid cluster for software upgrades", states the 2014 paper, thanks to node-by-node upgrades.
- Netflix in the loop: as early as 2012, Netflix was evaluating Druid to monitor real-time metrics of its streaming service.
Strengths and limitations
| Strengths | Limitations |
|---|---|
| Sub-second queries, fresh data included | Not a general-purpose warehouse |
| Scalable, compressed columns and bitmap indexes | Historically limited joins |
| Ideal for dashboards and metrics | Operating many services and dependencies (ZooKeeper, metadata, deep storage) |
| Immutable segments, upgrades without downtime | GPL licence [S] until 2015, seen as more restrictive by the press |
What came next
- Competitors in real-time OLAP: ClickHouse and Apache Pinot.
- Complements table formats such as Iceberg, which Druid can read as a source.
- Streaming ingestion from Kafka, batch from Hadoop.
- Federated SQL engines such as Trino for exploration beyond dashboards.
Sources
raw-data/apache/druid/druid.md- https://web.archive.org/web/2016/http://druid.io/blog/2011/04/30/introducing-druid.html
- https://web.archive.org/web/2016/http://druid.io/blog/2012/10/24/introducing-druid.html
- https://web.archive.org/web/2016/http://druid.io/blog/2015/02/20/towards-a-community-led-druid.html
- http://static.druid.io/docs/druid.pdf (Yang et al., SIGMOD 2014)
- https://www.rilldata.com/blog/apache-druid-turns-10-the-untold-origin-story
- https://incubator.apache.org/projects/druid.html
- https://www.apache.org/foundation/board/minutes/Druid.html
- https://druid.apache.org/docs/latest/design/architecture
- https://web.archive.org/web/2015/https://gigaom.com/2015/02/20/the-druid-real-time-database-moves-to-an-apache-license/ [S]
- 2012 GPL licence: only sourced by Gigaom [S]; find a primary source.
- Date when Druid SQL (via Calcite) arrived, and the Kinesis ingestion mentioned by the previous page: not sourced here.
- "Historically limited joins": limitation kept from the previous page, plausible but not sourced.
- Correction applied: the previous page said "Apache project established in 2012"; 2012 is the code release, the ASF entry dates from 2018.