sxs, lxs and wxs

sxs is a single server codebase. A deployment can run several instances of that server, each hosting one or more capacities.

A capacity is a class of work with its own traffic pattern and resource cost. It is not a separate application: the same image can serve normal queries, consume ingestion jobs or run extractions, depending on its configuration.

Capacities, execution modes and resource profiles

Four concepts must be kept separate:

  • Delivery describes whether a data request is synchronous or an asynchronous export.
  • Execution mode describes where synchronous data work runs: main-loop or worker.
  • Resource profile describes how ClickHouse executes the query: normal or bulk.
  • Capacity describes what a server process is allowed to do.
ConceptScopeExamples
DeliveryClient-visible response modesync, export
Execution modeWhere synchronous data runsmain-loop, worker
Resource profileClickHouse execution policynormal, bulk
CapacityServer-side work classsdmx, loader, rpc, workers, exports

Neither delivery nor resource profile selects an execution mode by itself. See Execution modes and resource profiles for the full model.

The MODES environment variable selects the capacities hosted by a process. The name is historical: operationally these are capacities.

The capacities

CapacityWorkTypical host
sdmxHTTP/SDMX structure and data queriessxs
loaderIngestion and background jobslxs
rpcAMQP request/response serviceslxs
workersLocal worker execution for JSON/SDMX-CSV requestswxs
exportsDurable asynchronous exportswxs

The loader capacity handles dbmx.data.store, dbmx.structure.store, dbmx.data.transfer and job cancellation. workers enables local worker execution capacity; exports consumes the MongoDB export queue. Both can run locally in development or in dedicated wxs processes.

At the time of writing, MODES gates sdmx, loader, rpc, workers and exports.

  • workers enables local worker execution. Without it, eligible worker jobs are sent to the remote wxs queue.
  • exports starts the export consumer. Without it, the process remains export-producer only.
  • Neither capacity changes the execution mode or resource profile of a request. Those are selected separately by the worker/bulk thresholds and the request shape.

Why isolate capacities

Fast queries are latency-sensitive. Ingestion and extractions are not: they can consume CPU for minutes, grow the heap and open their own ClickHouse, MongoDB and AMQP connections. When both run in the same process, a large load or a bulk download can slow down interactive requests and an out-of-memory error takes the query process with it.

Separating capacities gives each workload:

  • its own event loop and heap;
  • its own CPU and memory budget;
  • its own ClickHouse and MongoDB connection pools;
  • its own AMQP consumer and failure domain;
  • independent scaling and rollout.

Isolation is not absolute: all processes still share MongoDB, ClickHouse, RabbitMQ, the network and the Kubernetes node pool.

Selecting capacities

A process selects its capacities with MODES:

# Fast query process
SERVICE_NAME=sxs
MODES=sdmx
# Ingestion and RPC process
SERVICE_NAME=lxs
MODES=sdmx,loader,rpc

SERVICE_NAME labels logs and identifies the MOM application. It does not enable work by itself; MODES does. If MODES is unset, all known capacities are enabled, so set it explicitly in a deployment.

Reference deployment: sxs + lxs

The production layout separates the query fleet from ingestion and RPC:

DeploymentKindReplicasSERVICE_NAMEMODESRole
sxsDeploymentN (16 in dbmx-prod)sxssdmxFast query serving
lxsStatefulSet1 (scalable)lxssdmx,loader,rpcIngestion and RPC

lxs exists to isolate ingestion and RPC traffic from the fast-query fleet:

  • Ingestion requests are stored in a durable MongoDB queue (the ingestions collection) and claimed with a lease, so several lxs replicas can process them concurrently without running the same ingestion twice. Each replica handles one ingestion at a time; N replicas give N concurrent ingestions.
  • Restarting lxs is safe: at startup it reclaims only ingestions whose lease has expired (their owner is gone) and requeues them, up to INGESTION_MAX_ATTEMPTS. A live replica's in-flight ingestion is never cancelled by another replica.
  • lxs also has sdmx enabled so the same HTTP routes are available, but query traffic is routed to the sxs service.
  • lxs readiness requires AMQP because of loader and rpc; sxs readiness does not.
  • Deploy the same image to both. The loader and RPC code must match the query code that created the ingestions.

See Ingestion queue for the lifecycle, statuses and settings.

All-in-one deployment

For development or small installations, one process can host everything:

SERVICE_NAME=sxs
MODES=sdmx,loader,rpc

This is simpler to run, but there is no workload isolation: a long ingestion or a large extract shares the process with interactive queries.

wxs deployment

wxs hosts the extraction capacities (workers and exports), leaving sxs dedicated to query serving and lxs to ingestion and RPC. The receiving sxs process still serves the normal, bulk and export APIs; wxs executes worker jobs and exports.

wxs is a worker execution deployment. It does not define a new resource profile: execution mode and resource profile are still selected on sxs.

See also