---
title: "How Kami scaled from 80M to nearly 2B events per week with ClickHouse"
description: "Kami's Postgres event tracking (Rails writing JSONB rows, queried via Redash) collapsed when COVID pushed weekly events from about 80M to nearly 2B."
url: "https://swe.quest/articles/how-kami-scaled-from-80m-to-nearly-2b-events-per-week-with-clickhouse-77ce1b06efbf532e"
canonical: "https://clickhouse.com/blog/how-kami-scaled-from-80m-to-nearly-2b-events-per-week-with-clickhouse"
source: "ClickHouse"
published: "2025-05-16"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["analytics","data-pipelines","postgres","scalability","schema-migrations"]
---

# How Kami scaled from 80M to nearly 2B events per week with ClickHouse

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-05-16, 7 min read, Case study. Original: [https://clickhouse.com/blog/how-kami-scaled-from-80m-to-nearly-2b-events-per-week-with-clickhouse](https://clickhouse.com/blog/how-kami-scaled-from-80m-to-nearly-2b-events-per-week-with-clickhouse)

## Summary

Kami's Postgres event tracking (Rails writing JSONB rows, queried via Redash) collapsed when COVID pushed weekly events from about 80M to nearly 2B. Read replicas, a message queue and NVMe storage only delayed the problem, and Citus and CDC tools like Debezium could not keep up. The team moved to ClickHouse using a custom Java Kafka consumer that turned JSON into structured columns, plus a manual backfill of historical events. They later added MaterializedPostgreSQL and Kafka syncs for production and CockroachDB CRM data, and built dbt daily per-user rollups that cut DAU queries from 3-4 minutes over 140B rows to about 1 second over 1.3B rows.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Scaling](https://swe.quest/tags/scalability.md) (Distributed systems)
- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)

## Prerequisites

- OLAP vs OLTP databases ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- Kafka basics ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))
- SQL analytics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

ClickHouse, PostgreSQL, Kafka, dbt, PeerDB, MaterializedPostgreSQL, Citus, Debezium

## Related posts

- [Data Hive: The story of beehiiv’s journey from Postgres to ClickHouse](https://swe.quest/articles/data-hive-the-story-of-beehiiv-s-journey-from-postgres-to-clickhouse-467867cb2bebb87b.md): ClickHouse · 2024-08-21 · Easy · 6 min read · Analytics & OLAP, Databases, PostgreSQL, Stream processing, Queues & messaging
  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.
- [“Just OLAP it”: How Ramp rebuilt its analytics platform on ClickHouse Cloud](https://swe.quest/articles/just-olap-it-how-ramp-rebuilt-its-analytics-platform-on-clickhouse-cloud-36298842faab88cc.md): ClickHouse · 2026-01-20 · Medium · 5 min read · Analytics & OLAP, Event-driven architecture, Data pipelines, PostgreSQL, Queues & messaging
  Ramp moved customer-facing spend analytics off its Postgres monolith after enterprise customers' reports on a single card-transactions table began taking 40+ seconds, and now serves them in milliseconds from ClickHouse Cloud.
- [How SewerAI is using ClickHouse to modernize sewer management at scale](https://swe.quest/articles/how-sewerai-is-using-clickhouse-to-modernize-sewer-management-at-scale-b730a0ec357c6359.md): ClickHouse · 2025-09-19 · Medium · 7 min read · Analytics & OLAP, Data pipelines, Performance engineering, Cost optimization, PostgreSQL
  SewerAI replicates its Postgres transactional data into ClickHouse via CDC (moving from Confluent/Debezium to self-hosted Debezium+Kinesis to PeerDB, and now ClickPipes) and uses materialized and refreshable materialized views to denormalize 40+ tables into a single hundreds-of-billions-row "Megatable" for real-time municipal analytics.
- [Front-end observability at scale: How OpenReplay captures billions of daily events in real time with ClickHouse](https://swe.quest/articles/front-end-observability-at-scale-how-openreplay-captures-billions-of-daily-b210d948927bb0e9.md): ClickHouse · 2026-10-21 · Easy · 8 min read · Analytics & OLAP, Observability, Data pipelines, PostgreSQL, Scaling
  OpenReplay, a self-hosted session replay and product analytics platform, moved behavioral event storage from Postgres to ClickHouse.
- [London Meetup Report: Scaling Analytics with PostHog and Introducing HouseWatch](https://swe.quest/articles/london-meetup-report-scaling-analytics-with-posthog-and-introducing-housewatch-ed6b50855ec52fa1.md): ClickHouse · 2023-07-05 · Medium · 4 min read · Analytics & OLAP, Performance engineering, Observability, Databases
  PostHog scaled its product analytics platform by moving from Postgres to ClickHouse, with an events table holding roughly 62 TB uncompressed for a single column.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
