All Questions
Scaling Writes medium

You have a high-concurrency counter. Instead of using heavy database locks, you implement Optimistic Locking. How does this work?

  1. A It queues requests in Redis.
  2. B It ignores concurrency conflicts.
  3. C It locks the entire table.
  4. D It uses a version number column. Updates only succeed if the version hasn't changed since the read (e.g., `UPDATE ... SET count=6, ver=2 WHERE id=1 AND ver=1`).

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions