# Deployment types

Cube Cloud provides you with three deployment types:

* [Development instance](#development-instance) — designed for development use
cases.
* [Production cluster](#production-cluster) — designed for production workloads
and high-availability.
* [Production multi-cluster](#production-multi-cluster) — designed for
demanding production workloads, high-scalability, high-availaility, and
advanced multi-tenancy configurations.

## Development instance

<InfoBox>

Available for free, no credit card required. Your free trial is limited to 2
development instances and only 1,000 queries per day. Upgrade to
[any paid plan](https://cube.dev/pricing) to unlock all features.

</InfoBox>

<div style={{ textAlign: "center" }}>
  <img
    alt="High-level architecture diagram of a Cube Cloud Development Instance"
    src="https://ucarecdn.com/adaa000a-c562-4eb4-9687-6f57f0f4c22b/"
    style={{ border: "none" }}
    width="100%"
  />
</div>

Development instances are designed for development use cases only. This makes it
easy to get started with Cube Cloud quickly, and also allows you to build and
query pre-aggregations on-demand.

Development instances don't have dedicated [refresh workers][ref-refresh-worker]
and, consequently, they do not refresh pre-aggregations on schedule.

Development instances do not provide high-availability nor do they guarantee
fast response times. Development instances also [auto-suspend][ref-auto-sus]
after 30 minutes of inactivity, which can cause the first request after the instance
wakes up to take additional time to process. They also have [limits][ref-limits]
on the maximum number of queries per day and the maximum number of Cube Store
Workers. We **strongly** advise not using a development instance in a production
environment, it is for testing and learning about Cube only and will not deliver
a production-level experience for your users.

You can try a Cube Cloud development instance by
[signing up for Cube Cloud](https://cubecloud.dev/auth/signup) to try it free
(no credit card required).

## Production cluster

<InfoBox>

Available on [all paid plans](https://cube.dev/pricing).
You can also choose a [deployment tier](/product/administration/pricing#deployment-tiers).

</InfoBox>

<div style={{ textAlign: "center" }}>
  <img
    alt="High-level architecture diagram of a Cube Cloud Production Cluster"
    src="https://ucarecdn.com/fcb57d7a-09ee-4854-9282-db443a5ee61d/"
    style={{ border: "none" }}
    width="100%"
  />
</div>

Production Clusters are designed to support high-availability production
workloads. It consists of several key components, including starting with 2 Cube
API instances, 1 Cube Refresh Worker and 2 Cube Store Routers - all of which run
on dedicated infrastructure. The cluster can automatically scale to meet the
needs of your workload by adding more components as necessary; check the page on
[scalability][ref-scalability] to learn more.

## Production multi-cluster

Production multi-cluster deployments are designed for demanding production
workloads, high-scalability, high-availaility, and large [multi-tenancy][ref-multitenancy]
configurations, e.g., with more than 100 tenants.

<InfoBox>

Available on [Premium and above plans](https://cube.dev/pricing).

</InfoBox>

It provides you with two options:
* Scale the number of [production cluster](#production-cluster) deployments
serving your workload, allowing to route requests over up to 10 production
clusters and up to 100 API instances.
* Optionally, scale the number of Cube Store routers, allowing for increased
Cube Store querying performance.

<div style={{ textAlign: "center" }}>
  <img
    alt="High-level architecture diagram of a Cube Cloud Production Multi-Cluster"
    src="https://ucarecdn.com/0ab1eb5c-7aba-4e9c-8951-1998d4b714f0/"
    style={{ border: "none" }}
    width="100%"
  />
</div>

Each production cluster is billed separately, and all production clusters can
use auto-scaling to match demand.

### Configuring production multi-cluster

To switch your Cube Cloud deployment to production multi-cluster, navigate to
<Btn>Settings → General</Btn>, select it under <Btn>Type</Btn>, and confirm
with <Btn>✓</Btn>:

<Screenshot src="https://ucarecdn.com/30e357ce-4252-4676-bb1d-e46eb1f753ef/"/>

To set the number of production clusters within your production multi-cluster
deployment, navigate to <Btn>Settings → Configuration</Btn> and edit
<Btn>Number of clusters</Btn>.

<Screenshot src="https://ucarecdn.com/1da76aca-200a-410a-b84c-59b3d14ced9f/"/>

### Routing traffic between production clusters

Cube Cloud routes requests between multiple production clusters within a
production multi-cluster deployment based on [`context_to_app_id`][ref-ctx-to-app-id].
In most cases, it should return an identifier that does not change over time
for each tenant.

The following implementation will make sure that all requests from a
particular tenant are always routed to the same production cluster. This
approach ensures that only one production cluster keeps compiled data model
cache for each tenant and serves its requests. It allows to reduce the
footprint of the compiled data model cache on individual production clusters.

<CodeTabs>

```python
from cube import config
 
@config('context_to_app_id')
def context_to_app_id(ctx: dict) -> str:
  return f"CUBE_APP_{ctx['securityContext']['tenant_id']}"
```

```js
module.exports = {
  contextToAppId: ({ securityContext }) => {
    return `CUBE_APP_${securityContext.tenant_id}`
  }
}
```

</CodeTabs>

<WarningBox>

If your implementation of `context_to_app_id` returns identifiers that change
over time for each tenant, requests from one tenant would likely hit multiple
production clusters and you would not have the benefit of reduced memory footprint.
Also you might see 502 or timeout errors in case of different cluster nodes would return different `context_to_app_id` results for the same request.

</WarningBox>

## Switching between deployment types

To switch a deployment's type, go to the deployment's <Btn>Settings</Btn> screen
and select from the available options:

<Screenshot
  alt="Cube Cloud Deployment Settings page showing Development Instance, Production Cluster, and Production Multi-Cluster options"
  src="https://ucarecdn.com/fbde6a1e-734a-4091-8edd-922dc1ee7e1c/"
/>

[ref-ctx-to-app-id]: /product/configuration/reference/config#context_to_app_id
[ref-limits]: /product/deployment/cloud/limits#resources
[ref-scalability]: /product/deployment/cloud/scalability
[ref-multitenancy]: /product/configuration/multitenancy
[ref-auto-sus]: /product/deployment/cloud/auto-suspension
[ref-refresh-worker]: /product/deployment#refresh-worker
