When designing a stateful stream processor for <60s MTTR, pair incremental RocksDB S3 checkpoints with 5s Aligned-to-Unaligned barrier fallback.
TL;DR30-second simplified summary▾
Incremental RocksDB hardlinks cut 30s uploads from 500 GB to ~1 GB, S3 refcounting protects shared SSTables, and Unaligned fallback prevents backpressure timeouts.
R & E · Requirements, State Volume & Incremental Upload Math.
500 GB of state across 200 tasks = 2.5 GB of RocksDB state per task.
Illustrative Sizing: A full 500 GB upload every 30s needs 500 GB / 30s = 16.7 GB/s (~133 Gbps) of S3 egress! With Incremental RocksDB Checkpoints, only MemTable flushes and compactions since Checkpoint N-1 create new SSTables. At 1M events/sec (~200 MB/s raw, ~20 MB/s dirty state churn after window aggregation), 30s of delta SSTables is only ~600 MB–1.5 GB cluster-wide (~3–8 MB per task)—uploading in <1 second!
Full 500 GB Snapshot (16.7 GB/s) vs. Incremental SSTable Deltas (~1 GB/30s)
- 500 GB uploaded every 30s
- 16.7 GB/s S3 saturation
- Processing stalls during upload
- Hardlink local snapshot (<10 ms)
- Upload ~1 GB new SSTables/30s
- Zero pause on event path
S · Storage: RocksDB Hardlinks & Shared S3 State Registry.
Because RocksDB SSTables are immutable, creating a local checkpoint (DB::CreateCheckpoint) simply creates OS hardlinks to active SSTable files in <5 ms—zero data copying!
Each task tracks shared_sstables already in S3. Checkpoint N only uploads new_sstables and writes a compact metadata manifest listing (sstable_id -> s3_uri) plus Kafka offsets. A Shared State Registry reference-counts every S3 SSTable across retained checkpoints.
Checkpoint Manifest -> Shared SSTable Refcounts -> S3 Objects
H & A · Barrier Injection, Alignment & Two-Phase Sink Commit.
The Checkpoint Coordinator periodically sends TriggerCheckpoint(N) to all Kafka Source tasks.
Each Source records its current Kafka partition offsets, snapshots nothing else, and injects Barrier(N) into all downstream partitions. Stateful operators align Barrier(N) across input channels, hardlink RocksDB, forward Barrier(N) downstream, and upload delta SSTables asynchronously.
Coordinator -> Source Barrier -> Operator Hardlink + Async S3 -> Sink Commit
D · Detailed Design: Unaligned Checkpoints Under Backpressure.
In Aligned Checkpointing, if Input Channel 1 delivers Barrier(N) while Input Channel 2 is backed up behind 50,000 buffered events, the operator blocks Channel 1 waiting for Channel 2's barrier.
Under heavy backpressure, waiting for Barrier(N) to crawl through full TCP/Netty buffers can exceed the 30s checkpoint timeout! Enabling Unaligned Checkpoints with aligned_timeout = 5s lets the operator flip immediately if alignment stalls >5s: Barrier(N) overtakes the input/output buffers and the operator persists those in-flight buffers into S3 alongside RocksDB state.
Aligned Barrier (<5s) -> Backpressure Stall -> Unaligned Spill -> Committed
- Problem
- How to keep 30s checkpoints completing on time across 500 GB of state even during downstream backpressure.
- Naive Solution
- Upload full 500 GB state synchronously or use strictly aligned barriers with no timeout.
- Why It Fails
- Full uploads saturate S3 at 16.7 GB/s; strictly aligned barriers time out whenever backpressure stalls one input channel.
- Alternatives
- Full synchronous snapshots vs. Aligned-only vs. Incremental RocksDB + Aligned-to-Unaligned Timeout.
- Engineering Decision
- Use Incremental RocksDB SSTable uploads (with Shared State refcounting) and Aligned Barriers with a 5s fallback to Unaligned Checkpoints.
- Trade-Offs
- Adds S3 reference-counting metadata management in exchange for <1 GB/30s uploads and backpressure-proof checkpoints.
During a downstream database slowdown, backpressure fills all Netty input buffers in your stream processor, and 30-second Aligned Checkpoints start timing out repeatedly. What fixes this without losing exactly-once guarantees?
E & D · Evaluation, Assumptions, Limitations & Glossary.
Recovery speed (<60s MTTR) assumes S3 download parallelism across all 200 tasks and bounded Kafka replay lag (<=30s).
Assumptions & Limitations: Incremental delta size (~1 GB/30s) assumes typical window/keyed churn (~10% dirty state/min). If RocksDB triggers a massive full-level compaction across all 500 GB simultaneously, newly written compacted SSTables can cause a temporary spike in incremental upload volume—pacing compaction bandwidth avoids S3 bursts.
Kafka Sources -> Barrier Operators (RocksDB) -> S3 Registry -> 2PC Sink
Practice: Make the trade-off yourself.
Why does an incremental RocksDB checkpoint create OS hardlinks (`DB::CreateCheckpoint`) instead of copying 2.5 GB of state files per task?