Race condition
A bug that happens when 2 processes touch the same data at once and one overwrites the other's work.
Example
2 requests read 99, both store 100, and 2 got in with room for 1.
Test yourself: Race condition
Rate limiting
Reading the counter, adding 1 and storing it is the naive «get then ___» approach.
Between reading and storing there are a few ms in which 10 other requests can read the same value.
Generating unique keys
2 servers ask for a key in the same millisecond. What stops them from getting the same one?
The lock makes 1 of the 2 wait a few ms and get another key.
0/2
â–¶ Play