Real-Time OLAP Databases (Apache Druid, Apache Pinot, ClickHouse)
Serve sub-second analytics on event streams with Druid, Pinot, or ClickHouse.
In plain words
Kafka stream and durable offset/checkpoint. Next, segments/parts, sort/index, rollups. Finally, merge, late events, retention, replicas.
Think of it like…
Real-time OLAP is a market ticker newsroom: events are indexed into query-ready summaries as they arrive, while nightly compaction turns loose dispatches into organized editions.
Where you’ve seen it
Druid/Pinot ingest Kafka into near-real-time segments, later compact/roll up; ClickHouse's MergeTree sorts by (tenant_id,event_time) and a materialized view pre-aggregates minute metrics for subsecond dashboards.
Words you’ll hear
- Druid
- A distributed analytics store organized around time-partitioned segments and bitmap/column indexes for event dashboards.
- Pinot
- A distributed real-time analytical store with segments, indexes, and low-latency Kafka ingestion.
- ClickHouse
- A columnar MergeTree-family OLAP engine with strong compression, vectorization, and materialized aggregation.
- Operational boundary
- High-cardinality exact distincts expand state, real-time ingestion can create many small segments, and a filter without a useful bitmap/sort/index path scans far more events than a subsecond SLO permits. Define dashboard query templates, pre-aggregate at supported grain, tune segment/part size and dimensions, cap exact cardinality, route late data/corrections, and benchmark ingestion lag separately from query p95.
Visual diagram
Theory & deep dive
Druid: the working mechanism
Apache Druid, Pinot, and ClickHouse ingest event segments/parts and serve low-latency slice/dice aggregations using columnar storage, indexes, sorted dimensions, replicas, and pre-aggregation strategies.
Kafka stream and durable offset/checkpoint. Segments/parts, sort/index, rollups, then concurrency, filters, exact/approx metrics; this exposes the state governed by ClickHouse.
Druid/Pinot ingest Kafka into near-real-time segments, later compact/roll up; ClickHouse's MergeTree sorts by (tenant_id,event_time) and a materialized view pre-aggregates minute metrics for subsecond dashboards.
Real-Time OLAP Databases: failure mode and production response
High-cardinality exact distincts expand state, real-time ingestion can create many small segments, and a filter without a useful bitmap/sort/index path scans far more events than a subsecond SLO permits.
Define dashboard query templates, pre-aggregate at supported grain, tune segment/part size and dimensions, cap exact cardinality, route late data/corrections, and benchmark ingestion lag separately from query p95. Track Ingest lag as "event time to query-visible state", and make Query p95 visible to the dataset owner.
How it works, step by step
Step 1 of 41. Ingest
Kafka stream and durable offset/checkpoint. Apache Druid, Pinot, and ClickHouse ingest event segments/parts and serve low-latency slice/dice aggregations using columnar storage, indexes, sorted dimensions, replicas, and pre-aggregation strategies.
- Ingest lag
- event time to query-visible state
- Pinot
- A distributed real-time analytical store with segments, indexes, and low-latency Kafka ingestion.
When to use it & trade-offs
What it is
Apache Druid, Pinot, and ClickHouse ingest event segments/parts and serve low-latency slice/dice aggregations using columnar storage, indexes, sorted dimensions, replicas, and pre-aggregation strategies. Druid/Pinot ingest Kafka into near-real-time segments, later compact/roll up; ClickHouse's MergeTree sorts by (tenant_id,event_time) and a materialized view pre-aggregates minute metrics for subsecond dashboards.
Why it matters: High-cardinality exact distincts expand state, real-time ingestion can create many small segments, and a filter without a useful bitmap/sort/index path scans far more events than a subsecond SLO permits. Define dashboard query templates, pre-aggregate at supported grain, tune segment/part size and dimensions, cap exact cardinality, route late data/corrections, and benchmark ingestion lag separately from query p95.
When to reach for it
- Serve sub-second analytics on event streams with Druid, Pinot, or ClickHouse.
- Choose Druid because it provides this capability: A distributed analytics store organized around time-partitioned segments and bitmap/column indexes for event dashboards.
- Keep evidence for Ingest lag at "event time to query-visible state" so the last production stage-Compact/correct - merge, late events, retention, replicas-remains testable.
When to avoid or be careful
- High-cardinality exact distincts expand state, real-time ingestion can create many small segments, and a filter without a useful bitmap/sort/index path scans far more events than a subsecond SLO permits.
- Do not conflate Pinot with Druid. The second concept contributes different behavior: A distributed real-time analytical store with segments, indexes, and low-latency Kafka ingestion.
- Release only after this guardrail is in place: Define dashboard query templates, pre-aggregate at supported grain, tune segment/part size and dimensions, cap exact cardinality, route late data/corrections, and benchmark ingestion lag separately from query p95.
Druid / Pinot / ClickHouse - roles, limits, and operating cost
Strengths: A distributed analytics store organized around time-partitioned segments and bitmap/column indexes for event dashboards. Apache Druid, Pinot, and ClickHouse ingest event segments/parts and serve low-latency slice/dice aggregations using columnar storage, indexes, sorted dimensions, replicas, and pre-aggregation strategies.
Watch out: High-cardinality exact distincts expand state, real-time ingestion can create many small segments, and a filter without a useful bitmap/sort/index path scans far more events than a subsecond SLO permits.
Strengths: A distributed real-time analytical store with segments, indexes, and low-latency Kafka ingestion. In this workflow it supports: Serve - concurrency, filters, exact/approx metrics.
Watch out: The operating cost is real: subsecond target by exact query template.
Strengths: A columnar MergeTree-family OLAP engine with strong compression, vectorization, and materialized aggregation. Its output can be checked with Segment/part size.
Watch out: Operating guardrail: Define dashboard query templates, pre-aggregate at supported grain, tune segment/part size and dimensions, cap exact cardinality, route late data/corrections, and benchmark ingestion lag separately from query p95.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for Druid, and how would Ingest lag reveal it?”
- “Why is Pinot distinct from this behavior: a columnar MergeTree-family OLAP engine with strong compression, vectorization, and materialized aggregation?”
- Production clue: High-cardinality exact distincts expand state, real-time ingestion can create many small segments, and a filter without a useful bitmap/sort/index path scans far more events than a subsecond SLO permits.
- Design probe: Define dashboard query templates, pre-aggregate at supported grain, tune segment/part size and dimensions, cap exact cardinality, route late data/corrections, and benchmark ingestion lag separately from query p95.
Benchmarks & rules of thumb
- Ingest lag
- event time to query-visible state
- Query p95
- subsecond target by exact query template
- Segment/part size
- small pieces add metadata/merge overhead
Common mistakes & follow-ups
Common interview mistakes
- High-cardinality exact distincts expand state, real-time ingestion can create many small segments, and a filter without a useful bitmap/sort/index path scans far more events than a subsecond SLO permits.
- Reporting success from a job exit code without checking Ingest lag and Query p95.
- Treating this example as complete without replay, rollback, or access boundaries: Druid/Pinot ingest Kafka into near-real-time segments, later compact/roll up; ClickHouse's MergeTree sorts by
(tenant_id,event_time)and a materialized view pre-aggregates minute metrics for subsecond dashboards.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: A distributed analytics store organized around time-partitioned segments and bitmap/column indexes for event dashboards.
- What does the recovery plan do when this occurs? High-cardinality exact distincts expand state, real-time ingestion can create many small segments, and a filter without a useful bitmap/sort/index path scans far more events than a subsecond SLO permits.
- When is Druid insufficient for Query p95, and what does adding Pinot cost in Ingest lag?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Real-Time OLAP Databases (Apache Druid, Apache Pinot, ClickHouse) with data engineer interview Q&A and hands-on practice.