Interview's MateData Engineer
Interview's Mate

Data Engineer

SQL · Spark · Lakehouse · Streaming

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Engineer topics
Lesson 133/ 160
07. Streaming & Real-Time Data Engineering

Real-Time OLAP Databases (Apache Druid, Apache Pinot, ClickHouse)

Serve sub-second analytics on event streams with Druid, Pinot, or ClickHouse.

AdvancedDruid · Pinot · ClickHouse3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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

Loading interactive 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.

Real-Time OLAP Databases in one concrete design

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.

Key takeaway: 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

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.

Key takeaway: 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.

How it works, step by step

Step 1 of 4
Druid

1. 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.

Kafka stream and durable offset/checkpoint
Key numbers at this step
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

Druid
Best for: A distributed analytics store organized around time-partitioned segments and bitmap/column indexes for event dashboards.

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.

Pinot
Best for: A distributed real-time analytical store with segments, indexes, and low-latency Kafka ingestion.

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.

ClickHouse
Best for: A columnar MergeTree-family OLAP engine with strong compression, vectorization, and materialized aggregation.

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?
Interview tip: Lead with the data path and failure boundary: 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. Then make the answer operational: 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.

Knowledge check

Loading quiz

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.

Open Data Engineer Q&A →Machine Learning Q&A
Previous topic
Managed Streaming Platforms (AWS Kinesis, Google Pub/Sub, Confluent Cloud, Redpanda)
Next topic
Materialized Streaming Views (RisingWave, Materialize)