r/Clickhouse • u/jrdi_ • 1d ago
Building a Serverless ClickHouse: splitting compute and storage with plain_rewritable
https://jordivillar.com/blog/building-a-serverless-clickhouse
A few weeks ago I shared ClickHamlet here, a serverless ClickHouse you can connect to with plain clickhouse client. A lot of the questions were about how it works, so I wrote it up.
Every table lives on S3 on plain_rewritable disks. The servers are stock clickhouse-server pods that start on the first query and stop when idle, with a small C++ router linked against ClickHouse's own code in front.
Some things that might be interesting here:
- single writer per service without a lease: Kubernetes only allows one pod with a given name
- readers attach the same tables with refresh_parts_interval
- router throughput went from 451 to 2713 queries/s, mostly by taking work off the Python controller
- backends run on spot, writers included, since they hold no data
The big gaps are still multiple writers (plain_rewritable has no coordination between servers) and schema changes. Happy to answer questions or hear where this breaks.


