Building a Medallion architecture for Bluesky data with ClickHouse
A Medallion pipeline (Bronze, Silver, Gold) in ClickHouse ingests and cleans the high-volume Bluesky Jetstream feed, which arrives with malformed JSON, inconsistent and invalid timestamps, recursive structures and frequent duplicates. Events are pulled with websocat into gzipped CSV files on GCS, then loaded into a Bronze ReplacingMergeTree table through S3Queue in ordered mode. The Bronze table uses the new JSON type with SKIP clauses to drop recursive paths. Materialized columns derive a consistent event timestamp per event kind and a cityHash64 dedup hash that excludes the crawl time. The design also accounts for most duplicates arriving within a 20-minute window, and the resulting tiers are publicly queryable at sql.clickhouse.com.
Related posts
- Building a Medallion architecture with ClickHouse
ClickHouse mediumAdept
The Medallion architecture's bronze, silver and gold tiers can be built entirely from native ClickHouse features instead of Spark and Delta Lake. Bronze uses insert-optimized MergeTree tables with the JSON type, materialized columns and TTL, fed by S3Queue, ClickPipes or Kafka. Silver is populated by incremental materialized views with dead-letter routing and ReplacingMergeTree for deduplication and CDC, which requires FINAL at query time. Gold uses refreshable materialized views for joins and denormalization, plus AggregatingMergeTree for precomputed aggregates, at the cost of data replication and extra pipeline management.
- Data Hive: The story of beehiiv’s journey from Postgres to ClickHouse
ClickHouse easyNovice
beehiiv replaced its Postgres-and-Ruby-queue analytics system, which struggled with billions of email events and had multi-hour reporting delays, with a Kafka-fed ClickHouse Cloud pipeline. The design leans on ReplacingMergeTree for idempotent ingestion and event replay, dictionaries to enrich inserts without joins, ephemeral columns for intermediate calculations, materialized views as pre-aggregated shadow tables with alternate sort keys, and window functions for analytics. After six months the system held over 33 billion raw events in 1.5 TiB compressed (13 TiB uncompressed), with 22 ms median and 85 ms average query times. Creators now see send performance within seconds instead of hours.
- Accelerating ClickHouse queries on JSON data for faster Bluesky insights
ClickHouse mediumAdept
Incremental materialized views feeding AggregatingMergeTree tables cut ClickHouse dashboard queries over 4+ billion Bluesky JSON documents (1.6 TiB) from 44–56 seconds to 3–7 ms. Partial aggregation states are computed only for newly inserted rows and merged in the background, so the pre-aggregated tables stay tiny (e.g. 892 rows, 11 KiB) and constant-size regardless of source growth. Query latency therefore stays flat as the source table grows, and memory drops from ~776 MiB to ~186 KiB per query. Three dashboard scenarios cover count, uniq-based unique-user counts and top-reposted posts, with DDL, materialized view definitions and execution statistics; the reposts dashboard runs with a 5-second delay.
- Building a product analytics solution with ClickHouse
ClickHouse mediumAdept
ClickHouse's in-house product analytics platform, Galaxy, stores over 20 billion events (14 TB, roughly 14x compression) in a single denormalized MergeTree table keyed on created_at. A single sparse table avoids join overhead, since ClickHouse's sparse serialization makes empty columns cheap. Columns used for cohorts and filters should be top-level rather than buried in a JSON payload. Incremental materialized views speed up the few dozen recurring queries, and a custom SDK handles event capture.
- Goldsky - A Gold Standard Architecture with ClickHouse and Redpanda
ClickHouse mediumAdept
Goldsky streams blockchain data to potentially thousands of customer ClickHouse clusters by indexing chains into per-data-type Redpanda topics (Avro, infinite retention via tiered storage), applying per-customer FlinkSQL filters, joins and aggregations in stream at up to 500k events/sec, and delivering results to ClickHouse. Backfills use a custom hybrid Flink source that reads history from ClickHouse and increments from Redpanda. The main ClickHouse lesson was tuning ReplacingMergeTree for duplicates and updates: emulating PREWHERE, partitioning, limiting FINAL threads and customer-specific ORDER BY keys. The Base chain dataset (over 1B trace rows, roughly 1 TiB uncompressed) is publicly queryable at sql.clickhouse.com.