What makes high concurrency possible
Fast individual queries are the foundation of high QPS. The less work each query does, the more queries a server can run at once. The main features that reduce per-query work are:- The sparse primary index of the MergeTree table engine family, which skips reading data that doesn’t match the query.
- Caches such as the query cache, which serves repeated
SELECTqueries directly from cached results. - Projections, which precompute data at insert time and can be selected automatically by ClickHouse, and materialized views, which store precomputed results in a separate target table that queries can read directly.
Controlling and limiting concurrency
By default, ClickHouse OSS doesn’t limit the number of concurrent queries. ClickHouse Cloud setsmax_concurrent_queries_for_all_users to 1000 by default. You can configure limits at several levels:
max_concurrent_querieslimits the total number of concurrently executed queries on the server.max_concurrent_insert_queriesandmax_concurrent_select_queriesapply the same limit toINSERTandSELECTqueries separately. All three default to0(unlimited).max_concurrent_queries_for_userandmax_concurrent_queries_for_all_userslimit concurrency per user or across all users.
Isolating workloads
To keep concurrent workloads from interfering with each other, ClickHouse provides:- Workload scheduling to regulate how CPU, memory, and IO are shared between workloads.
- Quotas to limit resource usage per user over a time interval.
- Restrictions on query complexity to guard against individual queries consuming excessive resources.
- Built-in role-based access control to scope what each user can query.