Endpoints vs. Task QueuesEndpoints are RESTful APIs, designed for synchronous tasks that can complete in 180 seconds or less. For longer running tasks, you’ll want to use an asynchronous
task_queue
instead.Launch a Preview Environment (Optional)
beam serve
monitors changes in your local file system, live-reloads the remote environment as you work, and forwards remote container logs to your local shell.
Serve is great for prototyping. You can develop in a containerized cloud environment in real-time, with adjustable CPU, memory, GPU resources.
It’s also great for testing an app before deploying it. Served functions are orchestrated identically to deployments, which means you can test your Beam workflow end-to-end before deploying.
To start an ephemeral serve
session, you’ll use the serve
command:
multiply
function in app.py
, run:
Ctrl + C
in the terminal where you started the session.
Serve sessions end automatically after 10 minutes of inactivity. The entire
duration of the session is counted towards billable usage, even if the session
is not receiving requests.
By default, Beam will sync all the files in your working directory to the
remote container. This allows you to use the files you have locally while
developing. If you want to prevent some files from getting uploaded, you can
create a
.beamignore
.Deploying the Endpoint
When you’re finished with prototyping and want to make a persistent deployment of the endpoint, enter your shell and run this command from the working directory:Show Logs
Show Logs
The container handling the endpoint will spin down after 180 seconds of inactivity by default, or customized with the
keep_warm_seconds
parameter. The container will be billed for the time it is active and handling requests.