Scaling
sxs runs unchanged from a laptop to a large cluster. Scaling it is a matter of three independent levers:
- the query fleet — add stateless
sxsreplicas behind a load balancer; - workload isolation — split ingestion and extraction onto dedicated
processes (
lxs,wxs) using capacities; - the data stores — scale ClickHouse and MongoDB.
Principle
A deployment runs several instances of the same image. What each instance is
allowed to do is set by its capacities (MODES). Because work between them
travels through durable queues — MongoDB for ingestions, exports and remote
worker jobs; AMQP for events and RPC — and claims are leased, replicas can be
added or removed at any time without losing or duplicating work.
- the query fleet is stateless: scale it by replica count;
- ingestion and extractions are asynchronous and queued: scale them independently;
- all processes still share the same MongoDB and ClickHouse.
See sxs, lxs and wxs for the capacity model and Execution modes and resource profiles for how a request is classified.
Reference topologies
Scaling the query fleet (sxs)
An sxs instance handles HTTP requests on a single main thread (the Node.js
event loop), so one instance uses roughly one core for request handling, with a
small memory footprint. The most effective way to add bandwidth is to run more
replicas behind a load balancer (the Proxy sits in front of the fleet).
To protect the event loop from large or history queries, offload them to a worker:
- requests above
WORKER_OBS_COUNT_LIMIT(and allincludeHistory/updatedAfterrequests) run in a worker; - if the process has the
workerscapacity, the worker runs in a local pool; - if it does not (a pure
sdmxprocess), the job is sent to the remote wxs queue and executed bywxs.
So a common pattern is: many thin sxs replicas (MODES=sdmx) for latency, and a
separate wxs fleet for the heavy work. See
Bulk resource profile and worker jobs for thresholds and
classification.
Scaling ingestion (lxs)
Ingestion is asynchronous and durable:
- requests are stored in a MongoDB queue (the
ingestionscollection) and claimed with a lease; - AMQP uses a shared queue, so replicas are competing consumers — a message is processed by one replica only;
- each replica processes
INGESTION_PER_INSTANCEingestions concurrently (default1), so total concurrency is replicas ×INGESTION_PER_INSTANCE.
Adding lxs replicas is safe at any time: a restart reclaims only ingestions
whose lease has expired. See Ingestion queue.
Scaling extractions (wxs)
wxs hosts the workers and exports capacities:
- workers — a local pool of
node:worker_threadsexecutes worker jobs. Each worker is recycled afterWORKER_POOL_MAX_JOBSjobs and bounded byWORKER_POOL_MEMORY_MB; the pool queue is per process (WORKER_POOL_QUEUE_SIZE,WORKER_POOL_MAX_PER_SPACE). A full queue returns429withRetry-After. Scale by addingwxsreplicas. - exports — the export queue is durable in MongoDB and its concurrency
counters are shared across all replicas (backed by MongoDB), so limits such
as
EXPORT_MAX_PER_SPACEandEXPORT_MAX_PER_MEMBERhold fleet-wide. The same429/Retry-Afteradmission applies.
See Bulk resource profile and worker jobs and Asynchronous exports.
Scaling the data stores
When the observation volume grows, ClickHouse scales in two directions:
- vertically — add cores to the nodes;
- horizontally — shard the data and add replication.
sxs supports both: with a sharded cluster the normal resource profile queries
the distributed table (query spread across shards), while the bulk profile
queries the local table of a single shard and is throttled. This is how a
large extract is prevented from saturating the cluster — see
Execution modes and resource profiles.
For MongoDB, when the number of artefacts grows, use replica sets: sxs reads
with a nearest read preference, so read requests are spread across the nodes.
Sizing signals
Both fleets expose their state on the health endpoints:
- worker fleet —
/healthcheckreportsworkers(busy, queued,rejected) and per-worker heap usage; - ingestion fleet —
ingestionsstats (pending,processing,oldestPendingAgeMs).
Rules of thumb:
See also
- sxs, lxs and wxs — the capacity model.
- Execution modes and resource profiles — workers, bulk and thresholds.
- Bulk resource profile and worker jobs — the worker path.
- Ingestion queue —
lxs. - Asynchronous exports — the export queue.
- Configuration — all settings.
