Execution modes and resource profiles
sxs separates three concerns that must not be confused:
- Delivery — whether a data request is synchronous or an asynchronous export;
- Execution mode — where synchronous data work runs:
main-looporworker; - Resource profile — how ClickHouse executes the query:
normalorbulk.
Capacity (MODES) is a fourth, process-level concern: it decides what a process
is allowed to execute.
A synchronous request therefore has both an execution mode and a resource
profile. The two are independent: worker does not imply bulk, and bulk does
not imply worker.
The axes
Classification thresholds
Three settings drive classification:
The thresholds are independent. For example, with 10000 / 50000 / 5000000:
This example is illustrative. The default worker and bulk thresholds are infinite, so existing deployments are unchanged unless a threshold is set.
A request that exceeds SYNC_MAX_OBSERVATIONS is rejected with 413 unless it
is an asynchronous export. Exports use EXPORT_MAX_OBSERVATIONS instead and
bypass the synchronous cap.
How a request is classified
For SDMX-JSON and SDMX-CSV requests, classification follows these rules:
- A dimension-group-only request stays
main-loop/normal. - When the request has a
limitlower than or equal to both thresholds, it staysmain-loop/normal. - When the dataset total is lower than or equal to both thresholds, it stays
main-loop/normal. - Otherwise sxs counts the selected result. For a limited request the selected
page is the classification size; if that size is within both thresholds the
request stays
main-loop/normal. - The execution mode is
workerwhen the selected size exceeds the worker threshold; otherwise it remainsmain-loop. - The resource profile is
bulkwhen the selected size exceeds the bulk threshold; otherwise it remainsnormal.
For worker or bulk requests, the full filtered count is still recorded in the
worker job for statistics and Content-Range.
Series requests always count the filtered observations, because a series
limit/offset pages series rather than observations. Series limit and
offset are honored but never capped.
includeHistory and updatedAfter force the worker execution mode. They do
not force the bulk resource profile: a small history request is
worker / normal, while a history request whose result exceeds the bulk
threshold is worker / bulk.
Native formats bypass classification and the resource profile entirely. Native CSV, Parquet, Arrow, ArrowStream and Protobuf are streamed directly from ClickHouse and keep the normal cluster behaviour. They are still subject to the synchronous cap.
Multi-dataset requests are never offloaded to a worker. A multi-dataset request
that contains a bulk resource query, or that uses history/updated-after, is
rejected with 406.
Resource profiles
Normal
The normal profile is the interactive path:
- the distributed ClickHouse table is used when the cluster is sharded;
- normal cluster parallelism applies;
- the observation query cache is eligible;
- no bulk concurrency throttle is applied;
- no worker job is created.
Bulk
The bulk profile protects ClickHouse from concurrent large extracts:
- the local ClickHouse table is used instead of the distributed table;
max_threads = 1andtimeout_before_checking_execution_speed = 0.001;max_execution_speedis reduced as running worker jobs increase;- the observation query cache is bypassed;
- concurrency is throttled from the number of running bulk-resource worker jobs started in the last eight hours.
Only worker_jobs records with resource: bulk count toward this throttle.
Worker jobs with resource: normal do not consume bulk ClickHouse capacity.
Execution modes
Main-loop
The request is processed by the sxs main JavaScript thread. This is the lowest-latency path for small requests because there is no queue or thread handoff. It is also the most sensitive to CPU-bound work: a long build or serialization can delay other requests and health probes.
Worker
The ClickHouse query, SDMX building and JSON/CSV serialization run in a worker. The main thread keeps HTTP, queueing, response headers, backpressure and audit updates.
Worker eligibility currently requires SDMX JSON or non-native SDMX-CSV output, a single dataset, and an enabled worker pool. Native formats, dimension-group-only requests and multi-dataset requests stay in the main loop or stream directly from ClickHouse.
When a worker is not available, a request that would have used the worker falls
back to the main loop with the same resource profile. Set WORKERS_ENABLED=false
to disable both local worker execution and remote wxs dispatch entirely. The resource profile is
still applied, so the fallback keeps the local-table and throttling behaviour.
Worker jobs
Each worker job is recorded in the per-space worker_jobs collection. The
record includes:
queryId, dataset and dataset reference;obsMode(obsorseries);executionMode(main-looporworker);resource(normalorbulk);format,status,queuedAtandexecutionStartedAt;- the ClickHouse query and settings;
obsCount,seriesCount,runningBulks, host and node information;- worker runtime details, output size, cancellation and errors.
The status lifecycle is:
Records created before the split used runningMode and did not have
executionMode or resource. They are read as worker / bulk for backward
compatibility.
The sxsWorkerJobs RPC service exposes loadAll, loadOne, stats and
history. The old sxsBulks service is removed; Confy uses sxsWorkerJobs.
Capacities
MODES selects what a process is allowed to execute:
MODES=workers is a capacity switch:
- it enables local worker execution;
- without it, eligible worker jobs are sent to the remote wxs queue;
- it does not mean “this process handles only bulk resource queries”;
- it does not classify a request as normal or bulk.
A process with MODES=sdmx still serves normal, bulk and export APIs. It simply
does not execute worker workloads locally.
Why the separation matters
- The resource profile can be tuned independently from worker execution. A deployment can keep worker thresholds low for event-loop protection while keeping bulk thresholds high to avoid throttling ClickHouse.
- History requests can be moved off the event loop without being treated as large ClickHouse extracts.
- A worker can run normal-resource queries, so worker offload does not automatically consume bulk concurrency.
- Native formats can keep their direct ClickHouse path without being classified as bulk.
- A capacity can be added or removed without changing request classification.
Related documentation
- Bulk resource profile and worker jobs — classification, queue, worker execution and benchmarks
- Asynchronous exports — export API, statuses and retention
- Output formats — JSON, CSV, native CSV and Parquet
- sxs, lxs and wxs — deployment and
MODES - Configuration — thresholds, worker and capacity settings
- API — HTTP and RPC reference
