By default, Beam is serverless, which means your applications will shut off automatically when they’re not being used.

Configuring Keep Warm

You can control how long your containers are kept alive by using the keep_warm_seconds flag in your deployment trigger.

For example, by adding a keep_warm_seconds=300 argument to an endpoint, your app will stay running for 5 minutes before shutting off:

from beam import endpoint


# Container stays alive for 5 min before shutting down automatically
@endpoint(keep_warm_seconds=300)
def handler():
    return {}

When keep_warm_seconds is set in your deployment, it will count as billable usage.

Setting Always-On Containers

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

By setting min_containers=1, 1 container will always remain running until the deployment is stopped.

If you redeploy an app that has min_containers set, make sure to explicitly stop the previous deployment versions in order to avoid running containers that you are no longer using.

from beam import endpoint, QueueDepthAutoscaler


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