For everyone interested in lilac.codes, or have questions. Feel free to join discord.gg/aaFBUrCHm.
1
0
0
12
Smart Bob retweeted
@Shra_va_nierying `SELECT 1 FROM users WHERE username = ?` on every keystroke. at 500M users that would melt the primary database.
production systems use a 3-tier check:
1. Bloom filter at the edge:
a probabilistic bit array held in memory. 500M usernames with a 1% false positive rate requires only ~600MB of RAM.
- if the Bloom filter returns FALSE, the username is 100% available. zero downstream lookups needed.
- if it returns TRUE, it might be a false positive (~1%), so it falls through to:
2. Distributed in-memory cache (Redis cluster):
sharded by `hash(LOWER(username))`. a single in-memory `EXISTS` check resolves in sub-millisecond latency.
3. DB Unique constraint as the final safety net:
client keystrokes only check availability. when the user actually submits registration, an explicit `UNIQUE (LOWER(username))` constraint handles the in-flight race condition if two users claim the same available handle at the exact same millisecond.
production systems use a 3-tier check:
1. Bloom filter at the edge:
a probabilistic bit array held in memory. 500M usernames with a 1% false positive rate requires only ~600MB of RAM.
- if the Bloom filter returns FALSE, the username is 100% available. zero downstream lookups needed.
- if it returns TRUE, it might be a false positive (~1%), so it falls through to:
2. Distributed in-memory cache (Redis cluster):
sharded by `hash(LOWER(username))`. a single in-memory `EXISTS` check resolves in sub-millisecond latency.
3. DB Unique constraint as the final safety net:
client keystrokes only check availability. when the user actually submits registration, an explicit `UNIQUE (LOWER(username))` constraint handles the in-flight race condition if two users claim the same available handle at the exact same millisecond.
6
5
252
83,356
Smart Bob retweeted
Seeing generational levels of locked-in on the streets of SF
(face redacted to protect the innocent 🫡)
(face redacted to protect the innocent 🫡)
93
11
381
27,811
























