Load Testing: Ingest and Query Concurrency
How fast the 2 x 2 cluster ingests, how many dashboard queries it serves, and what saturates first
labs/loadtest.py writes 20 million rows four times (1, 2, 4 and 8
writers, 1 million rows per insert, through HAProxy and the Distributed
table), then runs a dashboard query (the last day, by country and hour,
with a p99) over the resulting 80 million rows at rising concurrency.
CPU per container comes from Docker's cumulative CPU counters, read
before and after each step.
docker compose -f compose_prod.yaml run --rm labs python loadtest.pyIngest
Ingest scales with writers until the nodes run out of CPU: each node is capped at 2 cores and used about 1.3 at 8 writers, while the Keepers used 0.1 core each. Keeper is not the bottleneck at this insert size, because 1-million-row inserts make few parts.
The first two runs of this lab got this badly wrong. They showed a flat
2.2 million rows/s, then a flat 1.33, with nearly idle nodes, and with 8
writers exactly the same 15.0 s as 1 writer. A constant time is a timer,
not a bottleneck: the run's clock included a CPU sampler that called
docker stats once per container, about 2 s each, one after another.
Seven containers plus a 2 s delay is 15 s. The sampler now reads
cumulative counters in parallel. The same runs also wrote only 16 of the
20 million rows with 8 writers (20 // 8 = 2 inserts each), and counted
the table before every replica had caught up.
Queries
Throughput stops growing at 4 clients, about 12 to 14 queries a second, when every node is at its 2-core limit. After that, more clients only queue: p99 goes from 0.3 s to 5.2 s at 32 clients for the same throughput. HAProxy used no measurable CPU.
Capacity planning from these numbers
- One dashboard query costs about 0.5 core-seconds here (8 cores busy for ~14 queries a second). A dashboard with 10 panels refreshing every 10 s per viewer costs about 0.5 core per viewer.
- Ingest is cheap next to that: 7.4 million rows a second used 5 cores in total.
- Concurrency limits belong on the server:
max_concurrent_queriesand per-usermax_threadskeep one dashboard from turning everyone's p99 into seconds. Pre-aggregation (the materialized views in chapter 6) is the bigger lever.
Numbers from one laptop, all 7 containers sharing it. Absolute values will differ on real hardware; the shapes (where throughput flattens, how p99 grows past it) carry over.