Inferensys

Glossary

Checkpointing

A fault-tolerance mechanism in stream processing that periodically saves the state of an operator or application to durable storage, enabling recovery from failures without data loss.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
FAULT-TOLERANCE MECHANISM

What is Checkpointing?

Checkpointing is a fundamental fault-tolerance mechanism in stream processing that periodically saves the state of an operator or application to durable storage, enabling recovery from failures without data loss or complete reprocessing.

Checkpointing is the process of creating a consistent, point-in-time snapshot of a stream processor's state and in-flight message positions. This snapshot, stored on a durable distributed file system, captures the exact progress of a stateful computation, including the current offset in each source partition and the values in local state stores. In the event of a failure, the system restores from the most recent checkpoint, rewinds the input stream to the recorded offsets, and resumes processing with exactly-once semantics.

Modern engines like Apache Flink implement asynchronous, distributed snapshot algorithms such as the Chandy-Lamport variant to perform checkpoints without pausing the entire data pipeline. Barriers are injected into the data stream to logically separate epochs, ensuring a globally consistent state across all parallel operators. The frequency of checkpointing directly impacts the recovery point objective (RPO); more frequent checkpoints reduce potential data replay but increase overhead on the stream processor.

FAULT-TOLERANCE MECHANISM

Key Characteristics of Checkpointing

Checkpointing is the backbone of reliable stream processing, ensuring that stateful operations can recover from failures without data loss or duplication. The following cards break down its essential properties and operational mechanics.

01

State Persistence to Durable Storage

Checkpointing periodically serializes the entire state of a stream operator—such as aggregations, counters, or window buffers—and writes it to a durable, distributed file system like HDFS, S3, or GCS. This snapshot includes the exact offset positions in the source partitions, creating a consistent recovery point. In the event of a failure, the operator is restored from this snapshot, and processing resumes from the stored offsets, guaranteeing exactly-once semantics when combined with idempotent sinks. The frequency of this operation is a critical tuning parameter: too frequent, and I/O overhead degrades throughput; too infrequent, and recovery time increases.

02

Barrier-Based Distributed Snapshots

Modern stream processors like Apache Flink implement checkpointing using the Chandy-Lamport algorithm adapted for continuous data flows. The job manager injects special records called checkpoint barriers into the data stream at the sources. These barriers flow through the entire directed acyclic graph (DAG) of operators, separating the stream into the portion that belongs to the current snapshot and the portion that belongs to the next. When an operator receives a barrier on all its input channels, it triggers a local state snapshot. This mechanism ensures a globally consistent snapshot across all parallel subtasks without stopping the entire pipeline.

03

Incremental vs. Full Checkpointing

Two primary strategies exist for managing state snapshots:

  • Full Checkpointing: The entire state is written to storage on every cycle. This is simple but becomes prohibitively expensive for large state sizes, causing significant backpressure.
  • Incremental Checkpointing: Only the changes to the state since the last checkpoint are persisted. This is the default in systems like Flink using RocksDB as a state backend. It dramatically reduces network I/O and storage costs, enabling checkpointing of multi-terabyte states at sub-second intervals. The trade-off is increased complexity in recovery, which requires replaying a chain of incremental files.
04

Unaligned Checkpointing for Backpressure

Standard aligned checkpointing requires barriers to wait at the input gates of an operator until all upstream channels have delivered their barrier. Under backpressure, a slow channel can stall this process indefinitely, causing the checkpoint duration to spike. Unaligned checkpointing solves this by allowing barriers to overtake buffered data. In-flight data that has not yet been processed is included as part of the channel state in the snapshot. This decouples checkpoint completion time from end-to-end latency, ensuring stable and predictable checkpoint durations even under heavy load, which is critical for latency-sensitive production pipelines.

05

Savepoints for Operational Agility

A savepoint is a manually triggered, externally managed checkpoint that serves a fundamentally different purpose from automatic failure recovery. While checkpoints are owned by the system and cleaned up automatically, savepoints are owned by the user and are immutable. They enable critical operational workflows:

  • Application Upgrades: Stop a job, upgrade the code or parallelism, and restart from a savepoint with zero data loss.
  • A/B Testing: Fork a production stream into a parallel experimental pipeline from a known consistent state.
  • Cluster Migration: Move a stateful job between different clusters or versions of the processing framework.
06

State Backend Configuration

The state backend is the pluggable component that determines where and how the operator state is stored during processing and checkpointing. The choice directly impacts performance and scalability:

  • HashMapStateBackend: Stores state as objects on the JVM heap. Offers the lowest latency for small to medium states but is limited by heap size and vulnerable to garbage collection pauses.
  • EmbeddedRocksDBStateBackend: Stores state in an embedded RocksDB instance on local disk. It supports massive states that exceed available memory by spilling to SSD, making it the standard for production workloads with large keyed states. Checkpointing flushes the local database to durable storage.
FAULT TOLERANCE

Frequently Asked Questions

Clear, technically precise answers to the most common questions about checkpointing in distributed stream processing systems.

Checkpointing is a fault-tolerance mechanism that periodically captures a consistent snapshot of a stateful stream operator's entire in-memory state and persists it to durable storage. This snapshot includes the current processing position (offsets) in the source data streams and any intermediate computation results. In the event of a failure, the system restores the operator to the most recent checkpoint and resumes processing from that exact point, ensuring exactly-once semantics without data loss or duplication. Unlike simple offset tracking, checkpointing preserves the full computational context—such as running aggregations, window states, and join buffers—allowing complex stateful pipelines to recover seamlessly.

FAULT-TOLERANCE MECHANISMS

Checkpointing vs. Savepointing vs. Log Compaction

A comparison of three distinct state management and recovery mechanisms used in distributed stream processing and event-driven architectures.

FeatureCheckpointingSavepointingLog Compaction

Primary Purpose

Automated failure recovery

Manual state snapshot for upgrades, migration, or rollback

Retain latest value per key; restore state from changelog

Trigger Mechanism

Automatic, periodic

Manual, user-initiated

Continuous background process

State Completeness

Full operator state graph

Full operator state graph

Only latest value per unique key

Retention Policy

Automatically pruned; short-lived

Persists until manually deleted

Retains latest record per key indefinitely

Recovery Speed

Fast; incremental restore from latest checkpoint

Slower; full state rebuild from savepoint

Fast; replay compacted topic from beginning

External Dependency

Durable distributed file system

Durable distributed file system

Distributed log (e.g., Kafka topic)

Supports Application Upgrade

Typical Use Case

Recovering from node failure in a Flink job

Upgrading a Flink job version without data loss

Rebuilding a state store for a Kafka Streams application

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.