Components
As shown in the diagram below, a typical production deployment of Cube includes the following components:- One or multiple API instances
- A Refresh Worker
- A Cube Store cluster
cube.js configuration file.
They also need access to the data model files. Cube Store clusters can be
configured via environment variables.
You can find an example Docker Compose configuration for a Cube deployment in
the platform-specific guide for Docker.
API instances
API instances process incoming API requests and query either Cube Store for pre-aggregated data or connected data sources for raw data. It is possible to horizontally scale API instances and use a load balancer to balance incoming requests between multiple API instances. The Cube Docker image is used for API Instance. API instances can be configured via environment variables or thecube.js
configuration file, and must have access to the data model files (as
specified by schema_path.
Refresh Worker
A Refresh Worker updates pre-aggregations and invalidates the in-memory cache in the background. They also keep the refresh keys up-to-date for all data models and pre-aggregations. Please note that the in-memory cache is just invalidated but not populated by Refresh Worker. In-memory cache is populated lazily during querying. On the other hand, pre-aggregations are eagerly populated and kept up-to-date by Refresh Worker. The Cube Docker image can be used for creating Refresh Workers; to make the service act as a Refresh Worker,CUBEJS_REFRESH_WORKER=true should be
set in the environment variables.
Cube Store
Cube Store is the purpose-built pre-aggregations storage for Cube. Cube Store uses a distributed query engine architecture. In every Cube Store cluster:- a one or many router nodes handle incoming connections, manages database metadata, builds query plans, and orchestrates their execution
- multiple worker nodes ingest warmed up data and execute queries in parallel
- a local or cloud-based blob storage keeps pre-aggregated data in columnar format

3030 for queries coming from Cube.
The port could be changed by setting CUBESTORE_HTTP_PORT environment variable.
In a case of using custom port, please make sure to change
CUBEJS_CUBESTORE_PORT environment variable for Cube API Instances and Refresh
Worker.
Both the router and worker use the Cube Store Docker image. The
following environment variables should be used to manage the roles:
| Environment Variable | Specify on Router? | Specify on Worker? |
|---|---|---|
CUBESTORE_SERVER_NAME | ✅ Yes | ✅ Yes |
CUBESTORE_META_PORT | ✅ Yes | — |
CUBESTORE_WORKERS | ✅ Yes | ✅ Yes |
CUBESTORE_WORKER_PORT | — | ✅ Yes |
CUBESTORE_META_ADDR | — | ✅ Yes |
Looking for a deeper dive on Cube Store architecture? Check out
this presentation
by our CTO, Pavel.