SSTables and Immutable Storage
What you'll learn: How immutable SSTables in wide-column stores like Cassandra enable high-performance writes and concurrent reads without locking.
What Are SSTables?
An SSTable (Sorted String Table) is an immutable, on-disk file that stores sorted key-value pairs. Once written, an SSTable is never modified—it's read-only forever. This immutability is a core design principle in wide-column stores.
When Cassandra flushes data from memory to disk (from the write path you learned earlier), it creates a new SSTable. Each SSTable contains a snapshot of data at that moment, sorted by key.
Why Immutability Matters
Immutable storage solves several challenging problems:
Fast Writes: Since SSTables are never updated in place, writes don't require seeking around on disk or locking files. New data just creates a new SSTable. No read-write conflicts exist—readers can safely access old SSTables while new ones are being written.
Concurrent Reads: Multiple read operations can scan different SSTables simultaneously without coordination or locks. There's no risk of reading "half-written" data because each SSTable is complete before it becomes visible.
Simple Recovery: Immutable files are naturally crash-safe. You never have a partially-corrupted SSTable from a failed write operation.
The Trade-off
The downside? Multiple SSTables may contain different versions of the same row. To read the latest value, the system must check several SSTables (using bloom filters to minimize disk reads). This is why compaction strategies exist—to merge old SSTables and reduce read amplification.
Think of SSTables like ledger pages that can never be erased. You add new pages but never modify old ones. To find the current balance, you read forward through all relevant pages.
Key Takeaway: SSTables are immutable, sorted files that enable fast, lock-free writes and concurrent reads in wide-column stores, trading write simplicity for the need to merge files during compaction.