About Deployment
Beam provides four abstractions to run your code on the cloud. We’ll walk through each one.
What does deployment mean?
To deploy an application means to run it on the cloud. When you deploy an app on Beam, it is containerized, scheduled, and loaded onto a cloud server. If you’ve deployed a Task Queue or REST API, it will also be exposed to users through an HTTP endpoint.
Beam provides four ways of running code on the cloud:
Run
, for running one-off tasksSchedule
, for running tasks on a schedule you’ve definedREST API
, for exposing an HTTP endpoint to run tasksTask Queue
, for exposing an HTTP endpoint to run tasks using a queueing system
These deployment strategies are exposed with decorators that you add above your Python functions.
Adding a deployment type
Once you’ve defined an App
and Runtime
, you can add a decorator to your function to set a deployment type.
Run
@app.run()
from beam import App, Runtime
app = App(name="your_app", runtime=Runtime())
@app.run()
def your_function():
print("This runs once!")
Schedule
@app.schedule(when="every 5m")
from beam import App, Runtime
app = App(name="your_app", runtime=Runtime())
@app.schedule(when="every 5m")
def your_function():
print("This runs every 5 minutes!")
REST API
@app.rest_api()
from beam import App, Runtime
app = App(name="your_app", runtime=Runtime())
@app.rest_api()
def your_function():
print("This runs when the API is called!")
Task Queue
@app.task_queue()
from beam import App, Runtime
app = App(name="your_app", runtime=Runtime())
@app.task_queue()
def your_function():
print("This runs when processed by the queue!")
Deploying an app
You’ll deploy your apps using the Beam CLI. If you’ve defined a Rest API, Task Queue, or Schedule type, you’ll use beam deploy
. If you’ve defined a Run, you’ll use beam run
.
Runs
beam deploy your_app.py:your_function
REST APIs, Task Queues, and Scheduled Jobs
beam deploy your_app.py
Next Steps
Was this page helpful?