Skip to main content

Serverless Workers

View Markdown

Serverless Workers let you run Temporal Workers on serverless compute. Deploy your Worker code to a serverless provider, configure a compute provider for the Worker Deployment Version, and Temporal starts and stops Workers in response to work on the Task Queue. There is no always-on Worker fleet to provision or scale.

Temporal monitors Task Queues that have a compute provider configured. When a Task arrives and no Worker is free to take it, the Worker Controller Instance (WCI) starts compute. How it starts compute is where the providers differ. On AWS Lambda, AgentCore Runtime, and Modal, the WCI invokes compute in response to unmet Task Queue demand. On GCP Cloud Run, it resizes a Worker Pool of long-lived instances that poll continuously.

Multi-cloud Replication for AWS and GCP compute

AWS Lambda, AgentCore Runtime, and GCP Cloud Run require the Namespace to be active in the same cloud provider as the compute. With Multi-cloud Replication, a failover to a different cloud provider prevents Temporal from starting new Workers on the original provider.

Choose a compute provider​

Choose based on how often Tasks arrive, how long Activities need to run, and what compute your Worker needs. An invocation timeout limits the lifetime of one Worker. A Workflow Execution can continue across multiple Worker invocations.

Compute providerChoose it whenTrade-offs
AWS LambdaTasks arrive in bursts or at intervals, and Activities are short. Examples include webhook processing and scheduled integrations in AWS.Temporal invokes a function on demand, so you can run without a standing Worker fleet. The first Task may wait for a cold start, and startup, Activity processing, and shutdown must fit within the function timeout.
GCP Cloud RunYou have a containerized Worker in GCP, steady Task Queue traffic, or Activities that need more time than a function invocation allows.Long-lived Workers poll continuously, and the pool can scale to zero if its minimum is zero. Keeping instances polling an idle Task Queue adds compute cost. You deploy a pool for each Worker Deployment Version and compute region.
Amazon Bedrock AgentCore RuntimeYour Python agent already runs on AgentCore, and you want its Temporal Worker to run there too.An AgentCore microVM session can run for up to eight hours. Your entry point must implement AgentCore's HTTP contract, and the session lifetime bounds the Worker.
ModalYour Python Activities need GPUs, for example for batch inference or media processing.Modal builds the container image from your Python definition and lets you configure compute resources and the function timeout. Worker startup depends on available container capacity. You need Pre-release access on Temporal Cloud and an authorized Modal workspace connection.

Try it locally​

To evaluate Serverless Workers on AWS Lambda without an AWS account, you can run the entire loop on your machine with LocalStack and the Temporal development server. See Test a Serverless Worker locally with LocalStack.