How Gmail checks username availability instantly (billions of users)

Started by Swati, Apr 17, 2026, 02:14 PM

Previous topic - Next topic

Rajendra


Yash

The username disappears before you even finish typing it.




Nitin

I search anything on Google and the results show up in about a second, even though there are trillions of data sources across the web.

Sneha


Kavitha

1] Indexed database
2] Hashing
3] Distributed systems like Google Spanner

These make lookup possible in O(log n), insanely fast.

Bonus:
They cache hot usernames - popular ones and recent queries.

All of this together makes it possible.

Harini

Many comments have already mentioned Bloom filters, but that's only part of the picture since they can tell if a username definitely doesn't exist. They can give false positives, saying a username may exist, so they're used as a fast pre‑check, not the final source of truth. There's a ByteMonk video https://youtu.be/_l5Q5kKHtR8 that explains this flow in detail - a must‑watch for me.