Skip to main content

Temporal Patterns

info

This page is part of the Temporal Platform Hub.

note

Curate Temporal Workflow patterns relevant to your use cases so developers can quickly find solutions.

Parallel Activity

What it doesExecute multiple Activities concurrently.
Why use itImprove Workflow performance when Activities are independent and don't need sequential execution.
Code samplesPython, Java

Custom Search Attributes

What it doesAdds custom key-value metadata to Workflow executions.
Why use itEnables advanced filtering, sorting, and visibility of Workflows in the Web UI and CLI based on business-specific data.
Code samplesPython, Java

Child Workflow

What it doesSpawns a new Workflow execution from within a parent Workflow.
Why use itPartition work into smaller chunks, encapsulates Activities into observable components, and model business entities with different lifecycles.
Code samplesPython, Java

Continue as new

What it doesAtomically completes the current Workflow execution and starts a new one with the same Workflow ID.
Why use itPrevents "Event History Limit Exceeded" errors and other Workflow Execution limits by clearing the history.
Code samplesPython, Java

Exception handling

What it doesImplements logic to catch and respond to Activity or Workflow failures.
Why use itEnsures system resilience by defining fallback logic, compensation transactions, or specific retry policies when errors occur.
Code samplesPython, Java

Cancellation

What it doesSends a request to gracefully terminate a running Workflow or specific scope.
Why use itStops unnecessary processing and cleans up resources when a result is no longer needed or a user explicitly stops the process.
Code samplesPython, Java

Async Activity completion

What it doesEnables the Activity Function to return without the Activity Execution completing.
Why use itEssential for long-running external processes that can heartbeat and inform Temporal of its completion.
Code samplesPython, Java

Local Activity

What it doesExecutes short-lived Activity logic within the same process as the Workflow Worker.
Why use itReduces latency and history size for short, high-throughput operations that do not require global durability guarantees.
Code samplesPython, Java

Batch Processing (Sliding Window)

What it doesProcesses a large stream of items in controlled, concurrent chunks.
Why use itManages concurrency and throughput limits while efficiently processing high volumes of data without overwhelming downstream services.
Code samplesPython, Java

Custom Metrics

What it doesEmits application-specific telemetry (counters, gauges, timers) from Workflows and Activities.
Why use itProvides observability into business-level KPIs and specific Workflow performance characteristics beyond default system metrics.
Code samplesPython, Java

Encryption

What it doesEncrypts Workflow and Activity payloads client-side using a custom Data Converter.
Why use itEnsures sensitive data remains secure and opaque to the Temporal Server, satisfying strict compliance and privacy requirements.
Code samplesPython, Java

Polling

What it doesPeriodically checks the state of an external system from within an Activity.
Why use itProvides reliable integration with external APIs or systems that do not provide webhooks or asynchronous event notifications.
Code samplesPython, Java

Worker routing

What it doesDynamically routes Activities to specific Task Queues monitored by designated Workers.
Why use itTargets tasks to specific hosts or environments; required for file-system affinity, local caching strategies, or hardware-specific (e.g., GPU) operations.
Code samplesPython, Java

Saga

What it doesManages long-running, distributed transactions by executing a sequence of steps. If a step fails, it triggers "compensating actions" (undo operations) in reverse order to revert the changes made by previous steps.
Why use itEnsures data consistency across microservices (e.g., booking a flight, hotel, and car) without locking resources for long periods. It handles partial failures gracefully by rolling back the system to a known consistent state.
Code samplesJava

Early Return

What it doesUses "Update with Start" to begin a Workflow execution and synchronously return a result to the client (e.g., validation success) while continuing to process longer-running tasks (e.g., database updates, external API calls) in the background.
Why use itDrastically reduces end-user latency in interactive applications. Users receive immediate feedback (like an "Order Received" confirmation) without waiting for the entire process to complete.
Code samplesJava

Example Temporal Applications

See Temporal Code Exchange for example Temporal applications.