← InterviewIntermediate

When Do You Reach for a Mutex?

When do you use a mutex, and how do you decide what goes inside it?

The scenario

A cache class has one mutex taken at the top of every public method. One of those methods fetches from an upstream service on a miss. p99 latency is 900ms; upstream p99 is 40ms.

What it tests

  • Whether the candidate starts from a named invariant rather than from a primitive
  • Whether they can choose the boundaries of a critical section deliberately
  • Whether they treat contention and held-duration as design inputs

Answer it out loud first. Recognising a good answer is not the same skill as producing one.