> ## Documentation Index
> Fetch the complete documentation index at: https://docs.beam.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Install the Beam CLI, sign in, and connect coding agents to the Beam MCP server with `curl -fsSL https://www.beam.cloud/install | sh`. To also create a VM, run `curl -fsSL https://www.beam.cloud/install | sh -s -- --vm`.
> VMs are persistent Linux machines without GPUs. Defaults: 4 CPUs, 8 GiB of RAM, a 50 GiB disk, Ubuntu 24.04, and a browser desktop. A running VM accrues usage until you stop, pause, or remove it, or until an idle timeout puts it to sleep.
> Stopping a VM keeps its disk and discards RAM and processes. Pausing keeps both, and resuming restores them. To pause after 5 idle minutes and wake on access, run `beam vm update NAME --ttl 300 --idle-action pause --auto-resume`.
> Core VM commands: `beam vm new NAME`, `beam vm ssh NAME`, `beam vm sync NAME ./dir`, `beam vm exec NAME -- CMD`, `beam vm expose NAME PORT --protected`, `beam vm fork NAME NEW_NAME`, `beam vm pause NAME`, `beam vm stop NAME`, `beam vm rm NAME`.
> For GPUs, use a sandbox or a deployed endpoint. Sandboxes are disposable environments that boot in seconds and fork from snapshots.
> Current rates are at https://www.beam.cloud/pricing.

# Scaling Out

You can scale out your app to multiple containers by adding autoscaling.

## Scaling Horizontally (Adding More Containers)

When you deploy a Task Queue or endpoint, Beam creates a queueing system that manages each task that's created when your API is called.

You can configure how Beam will scale based on how many things are in the task queue.

![](https://mintcdn.com/slai-beam/vg5aTEbpFmupCYom/img/v2/scaling.png?fit=max\&auto=format\&n=vg5aTEbpFmupCYom\&q=85\&s=e314e83f6738da09049a68a77c7651cd)

### Scale by Queue Depth

Our simplest autoscaling strategy allows you to scale by the number of tasks in the queue.

This allows you to control how many tasks each container can process before scaling up. For example, you could setup an autoscaler to run 30 tasks per container. When you pass 30 tasks in your queue,
we will add a container. When you pass 60, we'll add another containers (up until `max_containers` is reached).

```python theme={null}
from beam import QueueDepthAutoscaler, endpoint

autoscaling_config = QueueDepthAutoscaler(
    max_containers=5,
    tasks_per_container=30,
)

@endpoint(autoscaler=autoscaling_config)
def function():
    ...
```

## Setting Always-On Containers

> [!NOTE]
>
> Any running containers count towards billable usage. Take care to avoid
> setting `min_containers` unless you're comfortable paying for usage 24/7.

You can configure the number of containers running at baseline using the `min_containers` field.

By setting `min_containers=1`, the autoscaler maintains a target of at least one running container while the deployment is active, subject to capacity and runtime health.

```python theme={null}
from beam import endpoint, QueueDepthAutoscaler


@endpoint(
    autoscaler=QueueDepthAutoscaler(
        min_containers=1, max_containers=3, tasks_per_container=1
    ),
)
def handler():
    return {"success": "true"}
```

> [!WARNING]
>
> Review older active versions after redeploying an app with a warm minimum.
> Whether a prior version is stopped depends on the rollout strategy; see
> [deployment lifecycle](https://docs.beam.cloud/v2/hosting/deployments.md). Stop versions you no longer need.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.