RocksDB's Sequence Numbers Simplify Database Snapshots and Concurrency

Arpit Bhayani

Arpit Bhayani

Jun 27, 2026 • 1 min read


Here’s something interesting about RocksDB - it leverages ‘sequence numbers’ to make sure readers do not block writers. Let’s dig deeper…

Every write in RocksDB gets tagged with a monotonically increasing number. When you read a key, you’re not asking “what’s the latest value?” - you’re asking “what’s the latest value with a sequence number <= X?”

A snapshot becomes just a single number - no copying data, no freezing structures, just “remember this sequence number.” That’s pretty neat :)

Deletes and overwrites are just tombstones with higher sequence numbers. Old versions stay visible to older snapshots until compaction can safely drop them.

During compaction, RocksDB checks which snapshots are still alive and drops old versions that no active snapshot needs. The WAL replays operations in sequence order, restoring the exact same visibility rules and ensuring crash consistency.

So MVCC, snapshots, deletes, and compaction all rely on that sequence number that is stored next to every key. The design looks really simple, but it becomes surprisingly complex once you explore the implementation.

But, in any case, it is always fun to dig deeper into different databases; you will always find a new and interesting trade-off.

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses