Intermediate
Open
Pro
Choosing a Key Generation Strategy
Your team is debating how to generate 7-character keys for a new shortener. Three proposals are on the table:
- P1:
SHA-256(long_url)→ base62 → first 7 chars. - P2: a Postgres
BIGSERIALid → base62. - P3: a Key Generation Service that pre-generates random keys and hands blocks of 5,000 to each write server.
- For each proposal, name the single biggest weakness and how you would mitigate it.
- P3 seems best, but a colleague worries: "two servers could get the same key." Explain precisely how the KGS prevents that and what happens to keys held by a server that crashes.
- Which would you ship first for an MVP with 10 writes/s, and why?
Share this question