How Beam Works
Beam packages your code into a container and runs it on compute in the cloud. Beam’s runtime is powered by the open-source Beta9 orchestrator. Serverless containers scale within your autoscaler settings and workspace limits. Reserved machines and always-on configurations have different lifecycles; see pricing.The examples below use the Python SDK, which provides Beam’s decorator programming model. The TypeScript SDK offers programmatic access for creating sandboxes and calling deployed endpoints.
Sandboxes
A sandbox is a computer for an agent: a container you drive from code to start processes, read and write files, expose ports, and snapshot its filesystem or memory to fork it. Use sandboxes to give agents a machine to work in, and for development environments and RL rollouts. 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.