Paths Subjects Questions Quizzes Pricing Search
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 BIGSERIAL id → base62.
  • P3: a Key Generation Service that pre-generates random keys and hands blocks of 5,000 to each write server.
  1. For each proposal, name the single biggest weakness and how you would mitigate it.
  2. 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.
  3. Which would you ship first for an MVP with 10 writes/s, and why?

Share this question

← Back to Design a URL Shortener (bit.ly / TinyURL) practice

We use cookies for product analytics to improve OmniAtlas. See our Privacy Policy.