Serverless Workers
This page covers the following:
What is a Serverless Worker?
A Serverless Worker is a Temporal Worker that runs on serverless compute instead of a long-lived process. There is no always-on infrastructure to provision or scale. Temporal invokes the Worker when Tasks arrive on a Task Queue, and the Worker shuts down when the work is done.
A Serverless Worker uses the same Temporal SDKs as a traditional Worker. It registers Workflows and Activities the same way. The difference is in the lifecycle: instead of the Worker starting and polling continuously, Temporal triggers the compute environment, the Worker starts, processes available Tasks, and then exits.
Serverless Workers require Worker Versioning. Each Serverless Worker must be associated with a Worker Deployment Version that has a compute provider configured.
To deploy a Serverless Worker, see Deploy a Serverless Worker.
How Serverless invocation works
With traditional Workers, you start the Worker process, which connects to Temporal and polls a Task Queue for work. Temporal does not need to know anything about the Worker's infrastructure.
With Serverless Workers, Temporal starts the Worker.
The invocation flow works as follows:
- A Task arrives on a Task Queue that has a compute provider configured.
- Temporal's internal Worker Controller Instance (WCI) service detects that no Worker is polling the Task Queue.
- Temporal uses the compute provider configuration to invoke the serverless function. For example, calling AWS Lambda's
InvokeFunctionAPI. - The serverless function starts, creates a Temporal Client, and begins polling the Task Queue.
- The Worker processes available Tasks until the compute environment's deadline approaches.
- The Worker gracefully drains in-progress work and shuts down.
Each invocation is independent. The Worker creates a fresh client connection on every invocation. There is no connection reuse or shared state across invocations.
Compute providers
A compute provider is the configuration that tells Temporal how to invoke a Serverless Worker. The compute provider is set on a Worker Deployment Version and specifies the provider type, the invocation target, and the credentials Temporal needs to trigger the invocation.
For example, an AWS Lambda compute provider includes the Lambda function ARN and the IAM role that Temporal assumes to invoke the function.
Compute providers are only needed for Serverless Workers. Traditional long-lived Workers do not require a compute provider because the Worker process manages its own lifecycle.
Supported providers
| Provider | Description |
|---|---|
| AWS Lambda | Temporal assumes an IAM role in your AWS account to invoke a Lambda function. |