Temporal Use Cases and Design Patterns
This page provides an overview of how leading organizations leverage Temporal to solve real-world problems, general use cases, and architectural design patterns.
Use Cases of Temporal in Production
Here are some examples where Temporal is most impactful and running in production at large organizations today. For more examples, see our Temporal Use Cases page.
Transactions
Actions or activities involving two or more parties or things that reciprocally affect or influence each other. For example:
Business processes
A sequence of tasks that find their end in the delivery of a service or product to a client. For example:
- Bookings at Turo
- Orders/logistics at Maersk
- Marketing Campaigns at AirBnb
- Human-in-the-loop at Checkr
Entity lifecycle
Complex long-running processes that accumulate state over time. For example:
Operations
An automated method for getting a repeatable, mundane task accomplished. For example:
AI / ML and Data Engineering
AI and ML developers face challenges in system orchestration, such as managing complex data pipelines and job coordination across GPU resources. Temporal's code-first approach helps build reliable services faster, making it popular among AI companies. For example:
General Use Cases
Human in the Loop
"Human in the Loop" systems require human interaction for certain steps, such as customer onboarding, forms, or invoice approval. These are event driven system with humans generating events, and may be challenging to implement due to timing or unreliable connections between the human to the rest of the system. They can use schedules and timers to prompt for user input.
Example: Background checks example using the Go SDK.
Code Sample: Candidate acceptance example prompting for a response
Polyglot Systems
Modern development teams often work with different programming languages based on their expertise and project requirements. Temporal supports this through built-in multi-language capabilities, allowing teams to continue using their preferred languages while working together.
The example below showcases how Workflow Executions, written in different languages, can send messages to each other. Go, Java, PHP, and TypeScript SDKs are represented in this sample. It also shows how to properly propagate errors, including how to do so across Workflows written in different languages.
Example: Polyglot example.
Long Running Tasks
This use case is particularly relevant for scenarios like shopping cart Workflows in an eCommerce app, where you can handling long-running tasks efficiently without managing state in a separate database. It processes one message at a time, ensuring each message is processed only once.
This approach addresses issues that can arise with long message processing times, which in other systems might cause consumer failover (typically with a default 5-minute message poll timeout) and potentially result in duplicate message processing by multiple consumers. Temporal's ability to handle extended task durations makes it well-suited for such scenarios. The heartbeat feature allows you to know that an activity is still working, providing insight into the progress of long-running processes.
Example: eCommerce example.
Code Sample: Temporal eCommerce
Design Patterns
Saga
The Saga pattern is a design pattern used to manage and handle failures in complex Workflows by breaking down a transaction into a series of smaller, manageable sub-transactions. If a step in the Workflow fails, the Saga pattern compensates for this failure by executing specific actions to undo the previous steps. This ensures that even in the event of a failure, the system can revert to a consistent state.
Examples:
- Build a trip booking application in Python.
- Saga Pattern with Temporal Whitepaper
- To choreograph or orchestrate your saga, that is the question
- Saga Webinar
State Machine
A state machine is a software design pattern used to modify a system’s behavior in response to changes in its state. While state machines are widely used in software development, applying them to complex business processes can be a difficult undertaking. Temporal simplifies the complexity of state machines by providing a structured approach to workflow development, avoiding the intricate state management code required for state machines.
Example: State Machine Simplified Whitepaper
If you're interested in code to help get you started, check out our Temporal Example Applications, Getting Starting Tutorials, or Project-based Tutorials.