Cloudflare Distributed Databases Interview: Index Cover, MVCC Debugging, Read Replicas

Cloudflare Senior SWE, Distributed Databases: fewest composite indexes to cover a set of queries, an MVCC debugging round in a simulator, global read replicas.

CloudflareSenior Software Engineer, Distributed DatabasesUpdated Nov 21, 20262 min read

Interview Experience | Database | πŸ”₯πŸ”₯πŸ”₯ | Cloudflare

2026 (Oct-Nov) Senior Software Engineer, Distributed Databases @ Cloudflare β€” Austin, TX β€” Tech screen + Onsite β€” 3 rounds | Hard

Round 1 β€” Technical Screen

One engineer, 60 min, any language, I used Python.

The problem: a table has a batch of queries. For each query only the columns compared with = in the WHERE matter, so treat it as a set of columns. A composite index is an ordered list of columns. An index can serve a query iff the query's column set is exactly the first k columns of the index (order doesn't matter).

Part 1: given an index and a query, can the index be used.

index = (a, b, c)
{b, a} -> yes, first two columns
{a, c} -> no, b is missing in between

I compared lists in order at first, he reminded me the query is a set.

Part 2: given all queries, minimum number of indexes that covers every one.

queries = {a}, {a,b}, {b}
-> 2    (a, b) covers {a} and {a,b}, {b} needs its own

I started with greedy, longest chain first. He had a counterexample:

queries = {b}, {a,b}, {a,b,c}, {a,b,d}, {c}
greedy takes {b} βŠ‚ {a,b} βŠ‚ {a,b,c}, the other two need one each: 3
optimal is 2: (b, a, d) and (c, a, b)

Ended up on bipartite matching and got it written. Follow-ups: two queries with the identical set, and complexity.

Part 3: each query also has one range column, like a = ? AND b = ? AND ts > ?, and it has to come right after the equality prefix. Didn't finish, time ran out.

Round 2 β€” Debugging

One engineer, 60 min. A small MVCC KV store in Go, a few hundred lines, with a deterministic simulator, same seed fails at the same spot every time. No AI in this round.

The problem: the core logic is roughly:

Begin():  snap = lastCommitTs
Get(k):   newest version with commit_ts <= snap
Commit(): ts = ++lastCommitTs
          for k, v in writes: install(k, v, ts)

A failing seed, invariant is that a transfer keeps the total:

start A=50, B=50
T1: A -= 10; B += 10; Commit
T2 (read-only): Get(A), Get(B)
this seed: T2 reads A=40, B=50, total 90

First fix was one big lock, seed passed. He said install writes to disk and now every commit queues, think again.

Follow-up: another seed, two concurrent A -= 10, final A=40, should be 30. I broke that one myself when I split the lock.

Last one:

on_call: alice=1, bob=1, rule is at least one person on call
T1: reads both on call -> alice=0
T2: reads both on call -> bob=0
both commit, nobody on call

Does this store allow it, and how would you catch it. Barely started, ran out of time.

Round 3 β€” System Design

Design global read replicas for a database: writes go to the primary, reads go to the nearest replica, and a user who just wrote has to read their own write.

Requirements:

  • replicas can lag, but you can't send every read to the primary
  • the primary can fail over
  • no ordering guarantee needed between two different users

I first said pin the user to the primary for a few seconds after a write. He asked what if a replica is ten seconds behind.

Follow-ups:

  • same person on phone and laptop, two sessions
  • after failover, the position the client holds may never show up on the new primary. I missed this at first
  • the replication log format needs an upgrade and an upgraded replica can't roll back, how do you ship it. Didn't finish