Backend Concurrency

Two requests, one row. Optimistic versioning, pessimistic locks, atomic operations, and the bounded-resource thinking that keeps a burst from becoming an outage.

Backend Races

Two requests, one row: where concurrency bugs actually live in a backend, and why they never appear in development.

Q · Two requests read the same row, both decide it is fine, and both write. Which one is wrong?
Optimistic Concurrency

Read a version, write only if it has not changed, and treat zero rows updated as a conflict — never as success.

Q · How do I let two users edit the same record without one silently overwriting the other?
Pessimistic Locking

SELECT ... FOR UPDATE serialises access to a row — and holds a lock, a connection and a transaction while you do it.

Q · When is it right to stop other requests from touching a row rather than detecting that they did?
Atomic Operations

Do it in one statement the database evaluates indivisibly, instead of reading, deciding and writing from application code.

Q · Can the database make this decision for me, so there is no window for anyone to write into?
Unbounded Concurrency

Work that starts without a limit does not fail gracefully — it consumes memory, connections and downstream capacity until something breaks.

Q · What stops my service starting more work than it can finish?
Request Coalescing

When N concurrent requests need the same expensive result, do the work once and share it — the in-process answer to a stampede.

Q · A thousand requests all miss the cache for the same key at the same moment. Do I really run that query a thousand times?
Resource Limits

Every finite resource needs an explicit limit, or the system discovers its own — at the worst possible moment, in the worst possible way.

Q · Which limits does my service have, and which of them did I actually choose?