Klaviyo — Real-Time Segmentation
Klaviyo rebuilt real-time segmentation on a 192-node ClickHouse cluster using bi-level sharding, handling tens of billions of segment membership changes per day.
Scale
192-node cluster, billions of updates/day, tens of billions of segment membership changes across millions of segments
Before
Postgres/Redshift with high infrastructure cost and query latency — segment evaluation not viable at scale
After
ClickHouse with bi-level sharding (company ID → profile ID), keeping segment queries local to a shard
Key Insight
~60% of segments use time-based filters ('opened email 3–5 days ago') requiring constant reevaluation — extremely expensive at scale. The bi-level sharding design is what makes this tractable.
In a Snowflake Conversation
The bi-level sharding approach is elegant — shard by tenant first, then by entity within the tenant, which keeps segment queries local to a shard. This is the architectural insight that makes real-time segmentation at Klaviyo's scale work.
My Read
Practitioner commentary coming soon.
Relevant Conversations