Part 4 of 7 · 1 min read
The bottleneck
Many customers racing to update the same small set of seat rows.
Think of the bottleneck like fifty people all reaching for the same door handle at once. Even if each person only needs a fraction of a second to open it, the queue they form waiting their turn is where all the real delay happens.
In plain words: A naive UPDATE seats SET status = 'held' WHERE seat_id = ? AND status = 'available' run directly, with no further locking care, works correctly, since the WHERE status = 'available' check prevents double-selling. But with 100,000 customers racing toward the same 2,000 seats, the real-world failure mode is not correctness, it is throughput. Every seat's row becomes a hot row. Large numbers of transactions queue up waiting for the row-level lock each conflicting update takes, exactly the contention ratio problem identified in the numbers step.
The key lines.
-- Correct, but every popular seat row becomes a serialization point under load
UPDATE seats
SET status = 'held', held_until = now() + interval '5 minutes'
WHERE seat_id = 42
AND status = 'available';
Hot row
A hot row is a single database row that an unusually large number of concurrent transactions all try to read or write at once, becoming a serialization point that queues transactions behind each other.
Example: each of the 2,000 seat rows becomes a hot row during the first minute of a popular on-sale, as thousands of customers race to update the same handful of rows.