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. Temporal makes your applications reliable by default - ensuring that these failures don’t disrupt your application.

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

Temporal keeps track of the state of your application. If something goes wrong like a power outage, it helps your application pick up right where it left off - it’s like having the ultimate autosave. By offloading the responsibility of failure management from the application to the platform, this removes the need for extensive recovery coding, testing, and maintenance tasks.

This shift simplifies the development process and if a failure or a crash happens, your business processes keep running seamlessly without interruptions. This allows for developers to focus on business logic rather than infrastructure concerns and create applications that are inherently scalable and maintainable.

Thousands of developers trust Temporal for use cases like order processing, customer onboarding, and payment handling because it lets them build applications that are resilient, scalable, and just work – even when things go sideways. With Temporal, you're building applications that keep running, no matter what.

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 and are prone to failure 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 offers six SDKs: Java, Go, TypeScript, .NET, Python, and PHP. Installing the SDK allows you to easily add Temporal to your current projects without changing 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.

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.

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.

Workers, which are part of your application and provided by the Temporal SDK, then carry out the tasks and run your code. The Worker polls the Temporal Service to see if there are tasks available and the Temporal Service matches the Task with the Worker. The Worker runs the Workflow function based on the details specified in the Task.

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.

Workflows handle the overall control structure and Activities add retryable pieces that could potentially fail. Temporal handles everything from minor network outages to significant issues like unexpected reboots or hardware failures. 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.