Beam is serverless, which means your apps will scale-to-zero by default. Billing is based on the lifecycle of your containers. You are only charged when your containers are running.

What am I charged for?

You are charged whenever a container is running. This includes:

  • Running any code you’ve defined in an on_start function
  • Running your application code
  • Any keep_warm_seconds time. By default, containers will stay alive for 60s after the last request.

What am I not charged for?

  • Waiting for a machine to start
  • Pulling your container image

Real-World Example

You’ve deployed a REST API. You’ve added two Python Packages in your Image(), which are loaded when your app first starts.

You’ve also added a keep_warm_seconds=300, which will keep the container alive for 300 seconds (5 minutes) after each request.

app.py
from beam import endpoint


# This runs once when the container first starts
def load_models():
    return {}

@endpoint(keep_warm_seconds=300, on_start=load_models)
def predict():
    return {}

Let’s pretend you deploy this and call the API. Suppose it takes:

  • 1s to boot your application and run your on_start function.
  • 100ms to run your task.
  • 300s to keep the container alive, based on the keep_warm_seconds argument.

You would be billed for a total of 301.1 seconds.