How Temporal Works
Temporal provides a comprehensive platform for building distributed applications with a focus on durability and reliability.
Resilient applications by default
Temporal ensures your applications are reliable by default, handling everything from minor network outages to significant issues like unexpected reboots, application crashes, or hardware failures. By offloading the responsibility of failure management from the application to the platform, developers are freed from extensive coding, testing, and maintenance tasks.
This shift simplifies the development process and enables your application to seamlessly recover from disruptions. It does so by automatically reconstructing its previous state. Your application logic can be recovered, replayed, or paused from any previous point in the application process.
How It Works
Workflow
A Temporal application is the code you write, comprised of Workflow and Activities. Workflows are defined as code: either a function or an object method, depending on the language. A Temporal Workflow defines your overall business logic. That business logic might involve moving money between bank accounts, processing orders, deploying cloud infrastructure, training an AI model, or something else entirely. The Worker runs the Workflow and Activity code.
Activity
Activities are functions which encapsulate logic that can potentially fail, such as network calls, file operations, or random number generation. Activities are invoked in Workflow code and the Server coordinates with the application to execute them.
Server
Temporal consists of two components, the Server and an SDK in your preferred language such as Go, .NET, Java, Python, PHP, or Typescript. The Server logs the progress and state of your application. Once the application finishes executing the Activity, it communicates with the Server, which records the Activity's completion in the Workflow's Event History. The Activity invocation is handled by the Server. The Server updates the Event History and creates a Task for executing the Activity.
Recovering from Failure
A Temporal Workflow is basically a process or sequence of events you want to make sure will execute reliably. They can run—and keep running—for years, even if the underlying infrastructure fails. If the execution of your Workflow code crashes, Temporal automatically recreates its pre-crash state, allowing the Workflow to continue execution as if it never even happened. Temporal provides built-in solutions for timers, event sourcing, state checkpointing, retries, and timeouts, removing the necessity for custom implementations.
Concluding the Workflow
In this example, there are two Activities. The second Activity is complete, but the Workflow function sill has additional code to run. The Temporal Server creates a new Task requesting that the application run the additional code.
Follow one of our tutorials to Get started learning how to develop Workflows and Activities and run them in Worker Processes.
Or jump straight to a Temporal SDK feature guide:
- Go SDK Core application feature guide
- Java SDK Core application feature guide
- PHP SDK Core application feature guide
- Python SDK Core application feature guide
- TypeScript SDK Core application feature guide
For a deep dive into Temporal Workflows, Activities, and Workers, visit the following Temporal Encyclopedia pages or enroll in one of our courses: