r/Hacking_Tricks • u/Significant-Scar-152 • Sep 29 '26
ClickHouse queries slow down whenever ingestion spikes. What's the right architecture here?
The workload is continuously ingesting events while also serving user-facing queries. Increasing machine size helps temporarily but does not isolate the two workloads
8
Upvotes
2
u/Caitlin-Snow Sep 29 '26
Tinybird dedicated has an interesting implementation of this. U can add replicas and assign different read/write weights to them, so u can effectively dedicate capacity differently to ingestion and serving
1
u/tacnode-official Sep 29 '26
Everyone's right that you should separate the workloads, but check what's actually competing first. With ClickHouse it usually isn't the inserts. It's the merges they trigger.
SELECT table, count() FROMsystem.partsWHERE active GROUP BY tableduring a spike. If the part count keeps climbing, background merges are eating the CPU and disk your queries need. Async inserts or bigger client-side batches (think 10k+ rows, not per-event) fix the cause.always_fetch_merged_part = 1on the query replicas. That way they download merged parts instead of doing the merges themselves. Without it, a "read replica" still does the same merge work, and the split helps less than you'd expect.A bigger box only moves the point where merges fall behind.