Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Design a Real-Time
Log Analytics Pipeline.

At 600K events/sec (50 TB/day raw, 2.5M/sec bursts), traditional Elasticsearch clusters blow past 80 TB SSD budgets and crash on dynamic JSON field explosions.
Start the journey5 stages
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When a single bottleneck threatens end-to-end availability, buffer zstd-compressed batches in Kafka, enforce a strict top-level schema + bounded `Map(String, String)` in Flink/Vector, store 7-day hot logs in ClickHouse `MergeTree` (~65 TB with `ZSTD(3)` + `tokenbf_v1`), and tier older partitions to S3 Parquet.

TL;DR30-second simplified summary
▾

Core Mechanics: Across 4,000 Kubernetes nodes generating 600,000 JSON events/sec (576 MB/s = 49.8 TB/day), traditional inverted-index stacks inflate 50 TB/day into 90+ TB/day—exceeding an 80 TB 7-day hot SSD budget by 7x.

Visual & Structural Flow: Depicts Fluent Bit -> Kafka (zstd) -> Flink Schema Guard -> ClickHouse + S3 (Fluent Bit (<150MB) -> Kafka (20TB zstd) -> ClickHouse (65TB 7d) -> S3 Parquet (365d)); Primary Sparse Index (tenant, service, ts) + tokenbf_v1 Bloom Filter (Daily Partitions -> Primary Key Granules -> tokenbf_v1 Filter -> ZSTD(3) Columns).

Trade-Offs & Production: Shipping directly from Fluent Bit to Elasticsearch couples 2.5M/sec incident bursts to storage, drops logs when indexers stall, and allows dynamic JSON mapping to explode cluster state. Meet < 5 s freshness, <= 80 TB hot SSD, and 365-day retention: Node Agent (Fluent Bit in C): Stays under 150 MB RAM / 2% CPU with a 2 GB filesystem ring buffer.

Failure Modes & Application: Columnar analytical stores have largely replaced full-text clusters for high-volume observability: Cloudflare, Uber & Datadog-Scale Telemetry: Pair Kafka buffering with ClickHouse MergeTree + S3 cold tiering to cut SSD costs 5x-8x.

Full walkthrough · 5 stages
01
STAGE 01 · WHY IT MATTERSL4 · FUNDAMENTALS

Why 50 TB/day log pipelines break on storage amplification and bursts.

Why this matters: The mechanism: understand how Why 50 TB/day log pipelines break on storage amplification and bursts works from first principles.

Think of Why 50 TB/day log pipelines break on storage amplification and bursts as the intuition layer for Design a Real-Time Log Analytics Pipeline: The mechanism: understand how Why 50 TB/day log pipelines break on storage amplification and bursts works from first principles.

Across 4,000 Kubernetes nodes generating 600,000 JSON events/sec (576 MB/s = 49.8 TB/day), traditional inverted-index stacks inflate 50 TB/day into 90+ TB/day—exceeding an 80 TB 7-day hot SSD budget by 7x. Worse, an outage triggers a 4x (2.5M/sec) log storm right when engineers need trace_id lookups in < 5 seconds.

02
STAGE 02 · IMPACTL5 · APPLIED DESIGN

Mapping explosions, log storms, and ClickHouse `Too many parts`.

Why this matters: The problem: see what breaks without Mapping explosions, log storms, and ClickHouse Too many parts under real concurrency or scale.

Three failure modes hit production log platforms:

  1. Dynamic JSON Key Explosion: Logging UUIDs as top-level JSON keys creates 500K+ columns/mappings, crashing metadata coordinators.
  2. Incident Feedback Loops: 2,000 pods logging stack traces saturate brokers and drop root-cause ERROR logs.
  3. Small-Insert Part Overload: Unbatched inserts into ClickHouse trigger Too many parts (300) rejections.
Burst-Decoupled Log Pipeline

Fluent Bit -> Kafka (zstd) -> Flink Schema Guard -> ClickHouse + S3

Fluent Bit (<150MB)Kafka (20TB zstd)ClickHouse (65TB7d)S3 Parquet (365d)1. 2GB ring buffer + drop DEBUG onstorm2. Micro-batch 100k rows/2s ->ZSTD(3) 8:13. TTL > 7d moves partitions toParquet

5:1 Kafka zstd compression and 8:1 ClickHouse columnar compression fit 7 hot days into ~65 TB inside the 80 TB cap.

Engineering Decision Framework
Problem
How to implement Design a Real-Time Log Analytics Pipeline without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
When a single bottleneck threatens end-to-end availability, buffer zstd-compressed batches in Kafka, enforce a strict top-level schema + bounded Map(String, String) in Flink/Vector, store 7-day hot logs in ClickHouse MergeTree (~65 TB with ZSTD(3) + tokenbf_v1), and tier older partitions to S3 Parquet.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design a Real-Time Log Analytics Pipeline experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
STAGE 03 · NAIVE SOLUTIONL5 · APPLIED DESIGN

Naive direct-to-Elasticsearch shipping and schemaless indexing.

Why this matters: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.

Think of Naive direct-to-Elasticsearch shipping and schemaless indexing as the intuition layer for Design a Real-Time Log Analytics Pipeline: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.

Shipping directly from Fluent Bit to Elasticsearch couples 2.5M/sec incident bursts to storage, drops logs when indexers stall, and allows dynamic JSON mapping to explode cluster state.

Component Topology

Naive direct-to-Elasticsearch shipping and schemaless indexing

CalleringressRouter / APIcomputeProcessorstorageState Layercontrolrequestdispatchread/write
04
STAGE 04 · ENTERPRISE SOLUTIONL6 · SCALE & TRADE-OFFS

Enterprise solution: Priority Fluent Bit + Kafka + ClickHouse MergeTree + S3.

Why this matters: Operational control: configure bounds, failure handling, and safe production defaults.

Meet < 5 s freshness, <= 80 TB hot SSD, and 365-day retention:

  • Node Agent (Fluent Bit in C): Stays under 150 MB RAM / 2% CPU with a 2 GB filesystem ring buffer, priority shedding (drop DEBUG/INFO first during storms, preserve ERROR/FATAL), and zstd batching.
  • Kafka Buffer: 24 h retention at 5:1 zstd (~20 TB at RF=2 across 18 brokers), with per-tenant quotas.
  • ClickHouse Hot Tier (7 days): Promote 15-20 typed columns (LowCardinality(String) for service/env/level) and pack arbitrary keys into a bounded Map(String, String) (preventing schema explosion). ORDER BY (tenant_id, service, timestamp) with tokenbf_v1 bloom filters on message/trace_id and ZSTD(3) (~8:1 compression) fits 7 days at RF=2 in ~65 TB.
  • Cold Tier: ClickHouse TTL offloads >7d partitions to S3 Parquet for 365-day compliance.
ClickHouse MergeTree Layout

Primary Sparse Index (tenant, service, ts) + tokenbf_v1 Bloom Filter

Daily PartitionsTTL >7d -> S3 ParquetPrimary Key Granulestokenbf_v1 FilterPage 0ZSTD(3)Page 2Page 3

Sparse primary indexes and tokenbf_v1 bloom filters deliver <1.5 s p95 trace_id lookups without full inverted-index bloat.

CREATE TABLE logs_hot (
    tenant_id LowCardinality(String),
    service   LowCardinality(String),
    level     LowCardinality(String),
    ts        DateTime64(3),
    trace_id  String,
    message   String,
    attrs     Map(String, String), -- Capped dynamic keys
    INDEX idx_trace trace_id TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 4,
    INDEX idx_msg   message  TYPE tokenbf_v1(65536, 3, 0) GRANULARITY 4
) ENGINE = MergeTree()
PARTITION BY toYYYYMMDD(ts)
ORDER BY (tenant_id, service, ts)
TTL toDateTime(ts) + INTERVAL 7 DAY TO VOLUME 's3_cold';
05
STAGE 05 · SYSTEM DESIGN APPLICATIONSL7 · STAFF / PRINCIPAL

Where ClickHouse + Kafka log pipelines are used.

Why this matters: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.

Columnar analytical stores have largely replaced full-text clusters for high-volume observability:

  • Cloudflare, Uber & Datadog-Scale Telemetry: Pair Kafka buffering with ClickHouse MergeTree + S3 cold tiering to cut SSD costs 5x-8x.
  • Security & Audit SIEMs: Retain 365 days of Parquet in S3 queried via Trino/ClickHouse external tables.
Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why does ClickHouse with `LowCardinality(String)`, `ZSTD(3)`, and `tokenbf_v1` bloom filters replace Elasticsearch for a 50 TB/day log pipeline under an 80 TB SSD cap?

Recommended Learning Flow