Interview Q&A · questions with model answers

Database Concurrency & Scaling Interview Questions

Part of the study plan for: Data Engineer · Site Reliability Engineer (SRE) · Backend Engineer

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Most asked Why shouldn't you call a payment API inside a database transaction?

    The transaction holds row locks and a pooled connection for the whole call. A slow provider then blocks every other request needing those rows and exhausts the pool; and a rollback can't undo the…

  2. Why do 'get or create' operations deadlock on MySQL under load?

    Under Repeatable Read, SELECT … FOR UPDATE that finds nothing takes a gap lock. Two transactions can both hold the gap lock; each insert then needs an insert-intention lock that conflicts with the…

  3. Why does changing `id % 8` to `id % 12` make resharding painful, and what's the alternative?

    Changing the modulus remaps about two thirds of keys, forcing a huge data move. Consistent hashing or a fixed number of logical shards mapped to servers moves only the share that new servers should…

  4. Why might you avoid running reports on the primary database?

    Long analytical queries compete for CPU and I/O with user traffic, hold old snapshots that delay VACUUM (bloat), and can block or be blocked by DDL. Run them on a dedicated replica or warehouse fed…

Was this page helpful?

Report a mistake