System Design · Data Structures

“Username already taken”: how does Gmail know in milliseconds?

Press Learn from the beginning to walk through it step by step, or Play to watch it check a stream of names. Hover any box for a one-line reminder.

Checks
0
From RAM only
0 no I/O
DB queries
0
False positives
0
Candidate name—typed on the signup form
k = 3 hash functions
h₁ –h₂ –h₃ –
Verdict—waiting…
Bloom filter · m = 24 bits · in RAM
Cache + DBthe expensive truthasked only on “maybe”
1 / 8

the filterm = 24 bits, k = 3 hashes — every bit starts at 0
add "alice"h₁=5 h₂=12 h₃=21 → bits[5] = bits[12] = bits[21] = 1
check "zeynep_26"4, 9, 21 → bits[4] = 0 → FREE — answered from RAM
check "berkay"0, 9, 14 → all 1 → “maybe” → DB: taken
check "luna42"5, 17, 19 → all 1 → DB: free → false positive
speed 1×

Space plays or pauses · → next lesson