# Serverless Workers

> For the complete documentation index, see [llms.txt](https://docs.temporal.io/llms.txt).
> Any documentation page is available as raw Markdown by appending `.md` to its URL.
> For related questions, query `https://docs.temporal.io/api/retrieve?q=<question>&jtb=<job-to-be-done>&src=md-page&agent=<your-name>` (no auth; returns JSON `{content, source_url, page_url}`, with `source_url` pointing to Markdown for docs pages). Don't include personal data or credentials.
> If this page is wrong or missing something you needed, or Temporal behaves differently from what it says, report it with `https://docs.temporal.io/api/feedback?title=<summary>&message=<what-happened>&category=documentation&page_url=/production-deployment/worker-deployments/serverless-workers&src=md-page&agent=<your-name>` (use `category=product` when the product, not the page, is wrong). Report only a specific problem you hit, send it once, and don't include personal data or credentials.

> **Public Preview**
> AWS Lambda and GCP Cloud Run support are in Public Preview. Amazon Bedrock AgentCore Runtime and Modal support are in
> Pre-release. To request Pre-release access on Temporal Cloud, create a
> [support ticket](/evaluate/cloud/support#support-ticket) or contact your account team. You can also
> [sign up for updates](https://temporal.io/pages/serverless-workers-updates) or try AgentCore Runtime through self-hosting.

When a Task Queue needs more Worker capacity, Temporal starts Workers on the compute provider you configure for the
Worker Deployment Version. The compute provider determines how the Workers start, how long they can run, and what
resources they can use.

## How the compute providers differ

The [Worker Controller Instance (WCI)](/serverless-workers#how-invocation-works) monitors Task Queue demand. On AWS
Lambda, Amazon Bedrock AgentCore Runtime, and Modal, it invokes compute to start a Worker. On GCP Cloud Run, it adjusts
the size of a Worker Pool whose instances poll continuously while they run.

| Compute provider | What you deploy | How the Worker runs |
| --- | --- | --- |
| [AWS Lambda](/production-deployment/worker-deployments/serverless-workers/aws-lambda) | A Lambda function with a Temporal Lambda Worker integration. | Each invocation runs a Worker that starts up, polls for Tasks, and shuts down within the function timeout. |
| [GCP Cloud Run](/production-deployment/worker-deployments/serverless-workers/cloud-run) | A container image with a standard Temporal Worker and a Worker Pool for each Worker Deployment Version and compute region. | Long-lived Workers poll as long as their instances are running. The pool can scale to zero if you set its minimum to zero. |
| [Amazon Bedrock AgentCore Runtime](/production-deployment/worker-deployments/serverless-workers/agentcore) | An AgentCore Runtime endpoint whose handler starts a Temporal Worker. | The Worker runs in the background. Your handler controls idle shutdown and drain, subject to the Runtime session's lifecycle limits. A microVM session can run for up to eight hours. |
| [Modal](/production-deployment/worker-deployments/serverless-workers/modal) | A Python function in a Modal App, with its image and compute resources defined in Python. | Each invocation starts a fresh Worker with a configured timeout. Modal supplies container capacity and can reuse a container for later invocations. |

## Choose a compute provider 

Choose for the workload your Worker serves. Even within one application, a nightly batch and a customer-facing
Task Queue can have different needs for compute and startup latency.

### Start with the cloud your Activities use

If most of the systems your Activities call already run in **GCP**, start with **Cloud Run**. For example, a Worker
that reads from Cloud Storage and writes to a private Cloud SQL database can use your existing GCP identity and
deployment tooling, and reach private resources through [Direct VPC egress](https://docs.cloud.google.com/run/docs/configuring/vpc-direct-vpc#direct-vpc-workerpool).
Running the Worker in GCP can also avoid cross-cloud data transfers. You can deploy an existing containerized
Temporal Worker to a Worker Pool without adding a function handler.

If your dependencies are mainly in **AWS**, start with **Lambda** for short, intermittent work such as processing
webhook events, updating DynamoDB, or running scheduled integrations. If the application already runs on **AgentCore
Runtime**, deploy the Worker there to use the same runtime environment. Factor in the Runtime HTTP contract and the
idle and shutdown behavior your handler must implement.

Narrow your options to providers available in your Namespace and compute region. If a provider runs in a different
cloud from your Activity dependencies, factor in network access and data transfer costs.

> **⚠️ Caution:**
> 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](/cloud/high-availability#multi-cloud-replication), a failover to a different
> cloud provider prevents Temporal from starting new Workers on the original provider.
>

### Compare hardware and SDK support

Choose **Modal** for Python workloads that benefit from its GPU selection or Python-defined images, such as batch
inference or GPU-backed media processing. If your data and deployment tooling are already in GCP, compare Modal's GPU
options with the [GPUs available for Cloud Run Worker Pools](https://docs.cloud.google.com/run/docs/configuring/workerpools/gpu).
Modal also requires an authorized workspace connection to the Temporal Cloud account.

Your existing Worker code can narrow the choice. Cloud Run runs standard Temporal Workers. The Lambda deployment guide
covers Go, Python, TypeScript, Java, and .NET. The Modal integration uses Python, and the AgentCore guide shows a Python
Runtime handler.

### Match the Worker lifetime to your Activities

A Workflow Execution can span many Worker lifetimes. Compare providers using the longest **Activity attempt** you expect
a Worker to run.

- **Lambda and Modal** fit Activities that can finish within the time left in a function invocation after Worker
  startup and before shutdown. An Activity that starts late in an invocation has less time to finish.
- **Cloud Run** fits longer Activity attempts that would exceed a function deadline. A Worker Pool has no per-invocation
  timeout, though scale-in can still interrupt an Activity.
- **AgentCore Runtime** can suit longer Activity attempts in an existing AgentCore application. Both the maximum
  lifetime and the idle timeout can end the session. Polling Temporal does not reset the AgentCore idle timeout.

### Balance startup latency and cost

For a queue that's idle for hours at a time, start with on-demand invocations or a Cloud Run pool that can scale to
zero. The first Task after an idle period may wait for compute to start and the Worker to connect. For a GCP queue
with steady traffic or a tight Task pickup target, keep a minimum number of Cloud Run instances polling. In Modal,
keeping containers warm can reduce container startup time. Each invocation still starts and connects a new Worker.

If an existing fixed-size AWS Worker fleet handles most traffic, you can add [Lambda Workers on the same Task
Queue](/serverless-workers/aws-lambda#sharing-a-task-queue) to handle bursts.

Estimate cost using the time Workers actually run. A Lambda invocation can keep polling after it finishes a Task,
and Cloud Run charges for running pool instances even when they have no Tasks to process. Include the compute you
keep warm, any GPU capacity you reserve, and data transfers between regions or providers.

If you're choosing between providers that meet your requirements, compare the time to pick up the first Task from idle
and how quickly each provider clears a representative burst. Those measurements tell you whether you need to pay for
warm capacity to meet your latency target.

## 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](https://www.localstack.cloud/) and the Temporal development server. See
[Test a Serverless Worker locally with LocalStack](/production-deployment/worker-deployments/serverless-workers/aws-lambda/local-development).
