How Beam Works
Beam runs three kinds of compute in one workspace, with shared secrets, storage, and billing:- Virtual machines are persistent Linux machines. You create them by name, and they keep their disk until you remove them.
- Sandboxes are disposable environments that your code creates at runtime, uses, and terminates.
- Deployed apps are functions, endpoints, task queues, and pods. Beam packages your code or image into a container, scales it with traffic, and can scale it to zero.
Most examples below use the CLI or the Python SDK, which provides Beam’s decorator programming model. The JavaScript and TypeScript SDK creates and operates VMs and sandboxes and calls deployed endpoints.
Virtual Machines
A VM is a persistent computer for you or your agent: a named Linux machine with its own kernel, systemd, SSH, and a durable root disk. Installed packages, files, and services survive a stop and start, and pausing saves RAM and running processes too. Use VMs for coding-agent dev boxes, desktop automation, and agents that keep state between sessions. Learn more about VMs.Sandboxes
A sandbox is a disposable environment for running code: a container your code creates at runtime to start processes, read and write files, expose ports, and snapshot its filesystem or memory to fork it. Use sandboxes for untrusted or agent-generated code, RL rollouts, and short-lived GPU tasks. Learn more about Sandboxes.Functions
You can run functions on the cloud, either once, or on a schedule. Learn more about Functions.Functions
One-off Python functions, like training runs, scraping, or batch jobs.
Scheduled Jobs
Functions that run based on a schedule you specify.
Run Your Function
You’ll run your functions like a normal Python function:
python app.py.
Even though it feels like the code is running locally, it’s running on a
container in the cloud.Endpoints
You can also deploy synchronous and asynchronous web endpoints. Learn more about Endpoints and Task Queues. To call a model without deploying one, use hosted models.Endpoints
Synchronous REST API endpoints with a configurable request timeout.
Task Queues
Asynchronous REST API endpoints, for heavier tasks that take a long time to run.
Testing Your Code (Optional)
Beam provides a temporary cloud environment to test your code.
These environments hot-reload with your code changes. You can test your workflow end-to-end before deploying to production.
These environments hot-reload with your code changes. You can test your workflow end-to-end before deploying to production.
Deploying to Production
When you’re ready to deploy a persistent endpoint, you’ll use
beam deploy:beam deploy app.py:handler; calling .remote() runs one invocation. Cron schedules use UTC.
Apps, deployments, and containers
An app groups related versions. A deployment is a version of a workload’s code and configuration. A container is a running instance of that version; an active deployment can have zero containers while idle. A task records an invocation. A stub ID identifies a workload configuration and is distinct from the deployment and container IDs. Stacks group apps. References connect their environment variables to database credentials, secrets, or another app’s URL. Databases run as stateful services with durable disks.Web Services
You can also bring your own container and host web services, like Jupyter Notebooks, Node.js apps, and much more. Learn more about Pods.Pods
Run a container with HTTP or TCP ingress, or without ports for background work. For Dockerfiles and registry images, start with the container guide.