skip to content

Wide-Column Store Concepts

How a wide-column store behaves whatever product runs it: sorted keys that fix placement and order, log-structured storage, compaction and deletes, and its two replication models.

on this pageshow

questions

28

Why does a log-structured store delete data by writing a tombstone instead of removing it, and when is the deleted data physically removed?

level: juniorimportance: must knowfreq 58%

answer

  1. files cannot be edited
  2. a delete is a write
  3. the marker hides older data
  4. gone only after a merge

basics

~20 s

Its sorted files are immutable, so a delete is written as a marker, a tombstone, that hides older data for that key. The data and the marker disappear only when compaction merges the files holding them and it is safe to forget the delete.

solid answer

~50 s

A log-structured store never edits its sorted files, so it cannot erase a value in place. A delete is instead **written like any other mutation**: a **tombstone** carrying a timestamp, which travels through the log, the memory buffer and into a new file. At read time the tombstone **hides** every older entry for the same key or range, so the data looks gone immediately. Physically, both the old data and the tombstone stay on disk until **compaction** merges the files that hold them: when the tombstone meets the data it shadows, the data is dropped. The tombstone itself can be dropped only when nothing older could still reappear — once every file with older data for the key has been merged in and, in stores whose replicas reconcile with each other, after a grace period long enough for every replica to have seen the delete.

go deeper

for a junior

Know that a delete writes a tombstone that hides older data, and that space is reclaimed only later by compaction.

for a middle

Explain how a tombstone hides entries by timestamp and the conditions for dropping the data and the tombstone.

for a senior

Predict the space and read-latency effects of heavy deletes and design key layouts that delete by range or by file.

for a principal

Be ready to set data-deletion policies, such as retention and erasure deadlines, that account for how late space and data are really reclaimed.

## Why a delete cannot be an erase In a log-structured store: - data files are **immutable** sorted files, never edited after they are written; - a key's older versions may sit in several files; - replicas may hold their own copies. Erasing a value in place is impossible — there is no place to erase it from that would cover every copy. So a delete is recorded as **new information**. ## The tombstone A **tombstone** (delete marker) is a small entry saying *"everything for this key, up to this timestamp, is deleted"*. It can cover: - a single cell (one column of one row), - a whole row, - a range of rows or a whole partition, in stores that support range deletes. It is written through the normal path: commit log, memory buffer, flush into a new sorted file. ## Reading with tombstones When a read merges entries for a key, a tombstone **hides every entry with an equal or older timestamp**. Data written later, with a newer timestamp, is visible again. So from the application's point of view the delete takes effect immediately. ## When space is actually reclaimed Two things must happen before bytes are freed: 1. **The data is dropped** when compaction merges a file containing the tombstone with a file containing the older data it shadows. The merged output omits the shadowed data. 2. **The tombstone is dropped** when it is safe to forget that the delete happened: - no file outside the compaction still holds older data for that key (otherwise the data would reappear), and - in stores whose replicas reconcile by comparing data, a **grace period** has passed so every replica has received the delete. Stores where each key range is served by one server can drop delete markers at a **major compaction**, one that rewrites all of a range's files into a single file, because after it no older data can remain anywhere for that range. ## Consequences for design | effect | why | |---|---| | deletes use space at first | a tombstone is a new write, and the data is still there | | disk space returns late | it waits for the right files to be merged | | heavy deletes slow reads | reads must skip tombstones until they are purged | | bulk expiry is cheaper by file | dropping whole expired files avoids per-row tombstones | ## Interview angle Say why deletes are writes, how a tombstone hides older data by timestamp, and the two conditions for reclaiming space: merge with the data, then safely forget the marker.

  • Why does deleting a lot of data at first increase disk usage?
    Every delete writes a tombstone, and the deleted data stays in older files until compaction merges them. Until then the store holds both the data and the markers.
  • What does a range tombstone save compared with deleting rows one by one?
    One marker covers a whole range of rows instead of one marker per row, so fewer entries are written and reads skip one marker rather than thousands. Not every store or every key layout supports range deletes.

It is like correcting a bound ledger by adding a line that says "strike entry 42" instead of tearing out the page; the page is only removed when the ledger is recopied.

saying these in an interview costs you the question

  • Believing a delete immediately frees disk space
  • Saying deleted data is removed from the data file in place
  • Thinking a tombstone can be dropped as soon as it is written
  • Assuming data written after a delete with an older timestamp becomes visible
open as a page

What is the data model of a wide-column store, and why is it described as a sparse, sorted map rather than a table of fixed columns?

level: juniorimportance: must knowfreq 62%

basics

~20 s

A wide-column store maps a key plus a column name plus a timestamp to a value. Only the cells a row actually has are stored, so rows can differ in their columns, and rows are stored in key order.

open as a page

What path does a write take in a log-structured storage engine, from arrival to an immutable sorted file on disk?

level: juniorimportance: must knowfreq 60%

basics

~20 s

The write is appended to a commit log for durability and inserted into a sorted in-memory buffer, then acknowledged. When the buffer fills it is flushed to disk as a new immutable sorted file, and background compaction later merges those files.

open as a page

Why do you design a wide-column schema from the queries you will run rather than from the entities and their relationships?

level: juniorimportance: must knowfreq 66%

basics

~20 s

A wide-column store answers efficiently only reads that follow a key and its stored order, and it cannot join. So you list the application's reads first and give each one a key layout that serves it in one contiguous read.

open as a page

Which workloads is a wide-column store a good fit for, and what do you give up compared with a relational database?

level: juniorimportance: must knowfreq 64%

basics

~20 s

It fits very high write volumes, data that outgrows one machine, a small known set of queries, and time-ordered or sparse data. You give up joins, ad-hoc queries, rich secondary access and transactions spanning many rows.

open as a page

How do a wide-column store's two primary-key shapes, a hashed partition key with clustering columns versus one sorted row key, place and order rows?

level: middleimportance: must knowfreq 70%

basics

~20 s

With a hashed partition key, the hash picks the servers and clustering columns sort rows inside that partition. With one sorted row key, the whole keyspace is kept in byte order and split into contiguous ranges, each served by one server.

open as a page

When would you choose a B-tree storage engine over a log-structured merge engine, and what workload signals point each way?

level: middleimportance: must knowfreq 58%

basics

~20 s

Choose a B-tree engine for read-heavy work needing predictable point and range latency, since each key has one place. Choose an LSM engine for sustained heavy writes, since it writes sequentially and compresses well, at the cost of reads checking several files and background compaction.

open as a page

Why must a wide-column design bound how large one partition or row can grow, and how does adding a time bucket to the key bound it?

level: middleimportance: must knowfreq 54%

basics

~20 s

A partition or row is never split across servers, so one that grows forever becomes slow to read, compact and repair and can hit size limits. Adding a time bucket to the grouping part of the key starts a fresh partition each period.

open as a page

Why does a wide-column store make a query that filters on a non-key column expensive, and what should you do instead?

level: middleimportance: must knowfreq 58%

basics

~20 s

The key is the only structure that narrows a read, so a filter on another column makes the store read and discard data across partitions. Serve that read with a layout keyed by the field instead.

open as a page

Wide-column stores replicate either with leaderless replicas or with one server owning each key range. What does each model give a single-row read and write?

level: middleimportance: must knowfreq 52%

basics

~20 s

In the leaderless model any replica accepts a row's writes and the client chooses how many replicas must answer, so reads can be stale. In the range-owner model one server serves each key range, so single-row reads and writes are strongly consistent by default.

open as a page

In a replicated wide-column store whose replicas repair each other, why must a delete outlive replica repair, and what happens if its tombstone is purged too early?

level: seniorimportance: must knowfreq 46%

basics

~10 s

If a replica missed a delete and the others have purged the tombstone, repair sees the old data only there and copies it back. Tombstones must outlive the longest gap between successful repairs.

open as a page

How do size-tiered and leveled compaction differ in a log-structured store, and which workloads suit each?

level: middleimportance: should knowfreq 50%

basics

~20 s

Size-tiered compaction merges groups of similar-sized files into bigger ones, rewriting data rarely but leaving many overlapping files. Leveled compaction keeps each level's files non-overlapping, so reads touch few files and less stale data lingers, at the cost of rewriting data more often.

open as a page

How does time-to-live expiry work in a log-structured store, and why does expired data keep using disk space and read time until compaction?

level: middleimportance: should knowfreq 42%

basics

~20 s

A time-to-live stamps each cell or column group with an expiry; nothing is deleted at that moment. Expired cells are skipped when read or merged, and their space returns only when compaction rewrites or drops the files holding them.

open as a page

How do per-cell timestamps work in a wide-column store, and how does the store decide which value a read returns when a cell was written twice?

level: middleimportance: should knowfreq 48%

basics

~20 s

Every cell carries a timestamp, and when a cell has several writes the one with the highest timestamp wins. Some stores keep older versions readable up to a per-family limit; others show only the newest and discard the rest when files are merged.

open as a page

What is a column family in a wide-column store, and why does grouping columns into families affect storage, retention and read cost?

level: middleimportance: should knowfreq 45%

basics

~20 s

A column family is a named group of columns declared in the schema; the columns inside it are created freely by writes. Stores keep a family's data together and apply settings such as version retention per family, so grouping decides what a read touches.

open as a page

How does a read find a key in a log-structured engine that holds several sorted files, and how do bloom filters and file indexes limit the work?

level: middleimportance: should knowfreq 50%

basics

~20 s

A read checks the memory buffer and then every sorted file that could hold the key, merging entries so the newest version wins. Per-file bloom filters skip files that certainly lack the key, and per-file indexes jump straight to the right block.

open as a page

How do you turn a read such as "the latest orders for a customer" into a wide-column key, and why do the query's fields move into the key?

level: middleimportance: should knowfreq 56%

basics

~20 s

Put the fields the read matches exactly, such as the customer id, first in the key and the field it ranges over, such as order time, next, in the order it is read. A field only filters cheaply as part of the key.

open as a page

Why does time-window compaction suit time-series data with a fixed expiry in a log-structured store, and what kinds of writes break it?

level: seniorimportance: should knowfreq 40%

basics

~20 s

It merges each time window's data into one file that is never compacted again, so a fully expired window is dropped as a whole file. Back-dated writes, updates to old data and mixed expiries mix windows and defeat it.

open as a page

A wide-column table used like a queue, with rows inserted and soon deleted, reads more slowly over time even though little live data remains. Why, and how do you redesign it?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Every delete leaves a tombstone, and a read from the head of the range steps over all unpurged markers, so cost grows with deletes, not live rows. Read from a cursor, delete by bucket, or use a real queue.

open as a page

Why is a wide-column table's primary key effectively permanent, and what does changing the key of a live table actually involve?

level: seniorimportance: should knowfreq 40%

basics

~20 s

The key is the physical address, fixing where each row lives and its order on disk, so a store cannot re-key a table in place. Changing it means building a new table with the new key, backfilling, keeping both in step and cutting reads over.

open as a page

What are write, read and space amplification in a log-structured engine, and why can tuning never minimise all three at once?

level: seniorimportance: should knowfreq 38%

basics

~20 s

Write amplification is disk bytes written per byte the application writes; read amplification is work per read; space amplification is disk used per byte of live data. Merging files more eagerly cuts read and space costs but raises writes.

open as a page

In a wide-column design with a layout per read path, what must happen to the duplicated copies when a field that forms part of one layout's key changes?

level: seniorimportance: should knowfreq 40%

basics

~20 s

A key cannot be updated, so every layout keyed by the changed field must delete the row at its old key and write it at the new one. That needs the old value, read from the source of truth or carried in the change event.

open as a page

How does each wide-column replication model perform a conditional single-row write such as insert-if-absent, and why does its cost differ so much between them?

level: seniorimportance: should knowfreq 42%

basics

~20 s

A range-served store runs the check and the write atomically on the one server that owns the row, costing about a read plus a write. A leaderless store must run a consensus round among the row's replicas, adding several round trips and slowing under contention.

open as a page

When a server fails, how does availability differ between a leaderless wide-column store and one that serves each key range from a single server?

level: seniorimportance: should knowfreq 38%

basics

~20 s

A leaderless store keeps serving from the surviving replicas, as long as enough of them answer. A range-served store makes the failed server's key ranges unavailable until they are reassigned and any unflushed writes are replayed from the log.

open as a page

What atomicity can you rely on across rows in a wide-column store, and how do you design an operation that must change two rows?

level: seniorimportance: should knowfreq 46%

basics

~20 s

Atomicity stops at one row, or one partition in partition-keyed stores. Operations across rows have no isolation and can be partly applied, so put data that must change together under one key, or make multi-row steps idempotent and re-drivable.

open as a page

For a new write-heavy service, how would you choose between a leaderless wide-column store and one that serves each key range from a single server?

level: principalimportance: should knowfreq 30%

basics

~20 s

Choose by which failure the product tolerates and which operations it needs. Leaderless stores favour write availability and multi-site writes but make conditional updates costly; range-served stores give strong single-row reads and cheap check-and-mutate at the price of brief per-range unavailability.

open as a page

Why does a log-structured engine need a commit log when it flushes its memory buffer to sorted files anyway, and when can old log segments be discarded?

level: middleimportance: nice to knowfreq 32%

basics

~20 s

The memory buffer is lost on a crash, so the commit log is what makes acknowledged writes recoverable; on restart it is replayed into a new buffer. A log segment can be discarded once every buffer holding its writes has been flushed to sorted files.

open as a page

For time-series data in a wide-column store, when would you store one row per event rather than one row per entity and period holding many cells?

level: seniorimportance: nice to knowfreq 30%

basics

~20 s

One row per event is simpler, copes with uneven or unbounded streams and slices any time range. One row per entity and period packs events compactly and reads a period in one fetch, but must stay bounded in size.

open as a page