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.
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:
- Mortgage underwriting applications at ANZ
- Menu versioning at Yum! Brands
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.
Code Sample: Candidate acceptance example prompting for a response
Polyglot Systems
Temporal supports multiple languages, allowing different teams to work in their preferred languages. Systems are built by people and teams with different language skills. An advantage of event-driven systems is they can interact via a specific protocol without having to be written in the same language.
Example: Polyglot example. An implementer can wrap existing code, a Typescript UI starting a Java Workflow which calls a Python Activity.
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