# 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**. Running the Worker in GCP
can simplify access to those systems, let you reuse your deployment tooling, and reduce cross-cloud data transfers.
You can deploy an existing containerized Temporal Worker directly to a Worker Pool.

If your dependencies are mainly in **AWS**, start with **Lambda** for short, intermittent work such as processing
webhook events or running scheduled integrations. Lambda is also a fit for an agent whose Activities make short calls
to Amazon Bedrock for model inference.

Choose **AgentCore Runtime** when you already deploy agents on AgentCore and want to manage the Worker through the same
deployment and monitoring tooling. For example, an agent's Activities might use AgentCore to access managed tools or run
code in a sandbox. A Worker can reuse initialized clients and caches across Tasks within its Runtime session. Adopting
AgentCore for the Worker also means maintaining a Runtime handler and its shutdown behavior. See the
[AgentCore and Lambda comparison](/serverless-workers/agentcore#choose-agentcore-or-lambda).

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).

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.

### Decide how much capacity to keep ready

Consider who waits for the first Task after a quiet period. A nightly import can usually wait for compute to start.
A customer waiting for a result may need a Worker already polling.

- **Intermittent work that can wait.** Use on-demand Workers or set the Cloud Run pool minimum to zero. Lambda fits
  sporadic AWS work that finishes within an invocation. Modal fits intermittent GPU work where you can let the
  containers scale down between batches.
- **Steady traffic or a tight pickup target.** If you run on GCP, keep a minimum number of Cloud Run Workers polling.
  You pay for those instances during quiet periods to keep Workers ready to pick up Tasks. A warm Modal container
  can shorten container startup. Each invocation still starts and connects a new Worker.
- **A steady baseline with occasional spikes in AWS.** If a fixed-size Worker fleet handles normal traffic, use
  [Lambda Workers on the same Task Queue](/serverless-workers/aws-lambda#sharing-a-task-queue) for the excess. This
  lets you size the standing fleet for normal traffic and invoke additional Workers during bursts.

## 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).
