PostHog Self-Hosted ClickHouseCalc Sizing: `sharded_events`, Funnels & MergeTree RAM
In our deterministic ClickHouseCalc model, PostHog `sharded_events` tables ordered by `(team_id, toDate(timestamp), event, cityHash64(distinct_id))` compress 920-byte JSON events by ~11.6x under ZSTD(3), keeping full-year B2C funnels on predictable NVMe tiers.
ClickHouseCalc Compression, RAM & TCO Schedule for posthog-self-hosted-events
| Ingestion Scale | Raw Volume | MergeTree NVMe Disk | Node RAM & vCPU | Modeled TCO Delta (2026-11-12) |
|---|---|---|---|---|
| 10M Events/Day (365d · 9.2 GB/d) | 3.36 TB Raw | 370 GB NVMe (ZSTD-3 + 22% Buffer) | 32 GB RAM / 8 vCPU (Full Stack) | ~$1,450/mo Metered SaaS vs $19.99/mo Hostinger KVM 8 |
| 100M Events/Day (365d · 92 GB/d) | 33.6 TB Raw | 3.7 TB NVMe/RAID | 64 GB RAM / 16 vCPU | ~$8,900/mo Metered SaaS vs $79.00/mo InterServer Ryzen |
| 500M Events/Day (365d · 460 GB/d) | 167.9 TB Raw | 18.5 TB RAID Array | 128 GB RAM / 24 vCPU | ~$32,000/mo Metered SaaS vs $149.00/mo Dedicated Ryzen |
ClickHouseCalc PostHog Events Ordering Key & `ReplacingMergeTree` Schema
CREATE TABLE posthog.events_analytics
(
uuid UUID,
event LowCardinality(String),
properties String CODEC(ZSTD(3)),
timestamp DateTime64(6, 'UTC') CODEC(DoubleDelta, LZ4),
team_id Int64,
distinct_id String CODEC(ZSTD(3)),
elements_chain String CODEC(ZSTD(3)),
created_at DateTime64(6, 'UTC') CODEC(DoubleDelta, LZ4)
)
ENGINE = ReplacingMergeTree(_timestamp)
PARTITION BY toYYYYMM(timestamp)
ORDER BY (team_id, toDate(timestamp), event, cityHash64(distinct_id), cityHash64(uuid))
SAMPLE BY cityHash64(distinct_id)
SETTINGS index_granularity = 8192;
ClickHouseCalc MergeTree Production Checklist for posthog-self-hosted-events
- Materialize frequently filtered JSON properties (`$current_url`, `$pathname`, `$browser`, `utm_source`) into `LowCardinality(String)` columns so funnel queries skip full-string JSON parsing.
- Budget at least 32 GB system RAM when co-locating PostHog web workers, Kafka/Redpanda, PostgreSQL, Redis, and ClickHouse on one Hostinger KVM 8 or UltaHost VDS.
- Include `SAMPLE BY cityHash64(distinct_id)` in your MergeTree key so exploratory 90-day cohort funnels can scan deterministic 10% user samples via `SAMPLE 0.1`.
ClickHouseCalc Engineering FAQ: posthog-self-hosted-events
- Why does ClickHouseCalc recommend ClickHouse Keeper instead of Apache ZooKeeper for PostHog clusters?
-
ClickHouse Keeper is implemented in C++ rather than Java, reducing Raft coordination memory overhead from ~2.5 GB JVM heap down to ~250 MB resident memory on self-hosted PostHog nodes.
- How does ClickHouseCalc separate PostHog session replay storage from MergeTree event tables?
-
We recommend keeping ClickHouse MergeTree strictly for structured event metadata while offloading compressed rrweb DOM replay blobs to S3 or local MinIO storage with a 14-to-30-day TTL.