Skip to main content

How Temporal Works

Temporal offers an entirely new way to build scalable and reliable applications.

Build Invincible Apps

In any complex system, failures are bound to happen, but how they are handled makes all the difference. Temporal makes sure that these failures don’t disrupt your application. Temporal ensures your applications are reliable by default, handling everything from minor network outages to significant issues like unexpected reboots or hardware failures.

Temporal keeps track of everything your application does, so if something goes wrong—like a power outage—it helps your application pick up right where it left off. Similar to when a video game crashes, you can continue from the last save point. Temporal ensures your application doesn’t lose any progress. This shift simplifies the development process and if a failure or a crash happens, your business processes keep running seamlessly without interruptions.

In a traditional non-Temporal application, if a crash occurs, the progress of your application is often lost. The application has no memory of what happened before the failure, requiring extensive error-handling and messy recovery code to resume. This process is time-consuming and error-prone, making it hard to ensure reliability.

This allows for developers to focus on business logic rather than infrastructure concerns and create applications that are inherently scalable and maintainable. Any business process that must be reliable and scalable is a potential candidate for Temporal, but common use cases include order processing, customer onboarding, and payment processing.

Temporal Application: The Building Blocks

In a Temporal application, the code you write is made up of Workflows and Activities.

Workflow

Conceptually, a Workflow is a sequence of steps. You've likely encountered Workflows in your daily life, whether it's:

  • Using a mobile app to transfer money
  • Purchasing concert tickets
  • Booking a vacation
  • Ordering a meal delivery
  • Filing an expense report
  • Creating a new employee onboarding process

In Temporal, a Workflow defines the steps your application takes to complete a task, much like a blueprint for your application. It’s your business logic, written in code, outlining each step in your process. This could be moving money between bank accounts, processing orders, deploying cloud infrastructure, or training an AI model.

Temporal isn’t a no-code Workflow engine. It is Workflows-as-Code. Instead of dragging and dropping steps in a visual interface, you write your Workflows in code in your favorite programming language, code editor, and other tools. This gives you full control and flexibility over your business processes, allowing you to build exactly what you need.

Activities

Activities are the individual tasks in your Workflow. These are tasks that often interact with the outside world such as sending emails, making network requests, writing to a database, or calling an API.

Specifically, Activities are pieces of code. They are either functions or methods depending on the programming language, that perform these tasks. Activities are called directly from within your Workflow code.

If an Activity fails, Temporal automatically retries it based on your configuration. Since Activities often rely on external systems, transient issues can occur - temporary problems like network failures, timeouts, or service outages. You have full control over how often and how many times these retries should happen for each Activity.

SDK

Developers create Temporal applications by writing code, just like you would to create any other software. To do this, you use an Temporal SDK, which stands for software development kit.

The Temporal SDK is an open source library that developers install in their application to use Temporal. It provides everything needed to build Workflows, Activities, and various other features in a specific programming language.

Temporal currently offers six SDKs: Java, Go, TypeScript, .NET, Python, and PHP. Installing the SDK allows you to easily add Temporal to your current projects without having to change the tools you're already using. Temporal fits right into your existing tech stack.

The Temporal SDK also makes it easier to implement complex tasks such as sync/async execution, automatically retrying failed tasks, scheduling tasks to run regularly, managing complex workflows such as SAGA compensation, and managing errors.

Describing a Temporal Application - How It Works

Temporal Service

Temporal has two main parts:

  1. Your application (with Workflows and Activities)
  2. The Temporal Service (a set of services and components)

At the heart of Temporal's architecture is the Temporal Service, which provides durability, scalability, and reliability for your application. It communicates with the application, manages tasks, and maintains a detailed history of each event, which it durably persists to a database. The Temporal Service manages critical tasks like making an API call or updating a database, by making sure they get executed, and then recording their completion.

One of the biggest advantages of the Temporal Service is how it handles failures. The Temporal Service maintains a meticulous log of every step in your Workflows. By keeping a history of every step in your Workflow, it ensures that even if something goes wrong — your Workflow can continue from the last successful point. The Temporal Service knows exactly where to resume without losing any work. This saves you from having to write complex error-handling code or recovery mechanisms yourself.

You can run the Temporal Service on your own infrastructure or use Temporal Cloud, a managed service that handles operational overhead and offers scalability and expert support.

Describing a Temporal Application and Temporal Service - How It Works

Workers

The real strength of Temporal comes from the combination of your application and the Temporal Service. The Temporal Service doesn't actually run the Workflow and Activity functions. A Worker, which is part of the application and is provided by the Temporal SDK, is responsible for running that code.

Workers execute the actual tasks defined in your Workflows. The Temporal Service tracks and coordinates these Workers.

Whenever your application needs to perform a task, like sending a notification or calling an processing a payment, the Temporal Service steps in. This process creates a clear, organized list of what needs to be done. It hands off tasks to these Workers, making sure they’re done correctly and efficiently while it keeps track of their progress. Workers, which are part of your application, then carry out the tasks and run your code. This collaboration is crucial for building reliable, scalable, and durable applications. You can run multiple Workers — often dozens, hundreds, or even thousands — to improve application performance and scalability.

Describing a Temporal Application and Temporal Service and Workers - How It Works

info

For a deep dive into how Temporal Service works, visit the Temporal Encyclopedia page.

Conclusion

Temporal provides effortless reliability, allowing applications to run for days, weeks, or even years without interruption. With Temporal, you don't have to write tons of extra code to handle every possible thing that could go wrong. Temporal supports multiple programming languages and simplifies state management. Temporal scales up easily, making sure everything runs smoothly, no matter how big your application gets.

If your Workflow crashes, it automatically recreates its pre-crash state and continues as if the failure never happened using data from the Event History. The Event History is a detailed log that records every significant action or decision made by the Workflow. Temporal automatically saves and restores your application's state, so you don't have to juggle that yourself. This means your application can keep running for days, weeks, or years, even if the underlying infrastructure fails.

Temporal also represents a paradigm shift in software development. It's not just about making existing patterns more reliable; it's about enabling entirely new approaches to building complex, distributed systems.

tip

Follow one of our tutorials to Get Started learning how to use a Temporal SDK.

Or jump straight into the SDK docs for your preferred language:

For a deep dive into how Temporal works, visit the Temporal Encyclopedia page.