Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Community URL Shortening Service

Design a URL shortener whose user-owned links support durable voting and queryable popularity rankings.

Problem statement

Design the storage model and end-to-end service for a community URL shortener. Users create short URLs that resolve to original HTTP(S) destinations. Each short URL belongs to its creator, and signed-in users may cast one upvote or one downvote per link and later change or remove that vote.

The system must answer two exact queries: links with the most upvotes and links with the highest net score, where net score is upvotes minus downvotes.

For this exercise, assume 100 million active links, 10 million daily users, 100,000 peak redirects per second, 5,000 peak vote writes per second, generated aliases that are never reused, and single-zone failure tolerance.

Link creation and vote changes require retry-safe identities; redirects must not wait on voting or ranking work. Ranking results may lag accepted votes by up to one minute, but a link-detail read must expose the current durable vote totals.

Custom aliases, expiration, deletion, malicious-link scanning, personalized ranking, comments, and follower graphs are outside scope.

Define schema and indexes, public and internal APIs, alias generation, redirect serving, vote uniqueness and changes, exact durable counters, asynchronous ranking projections, consistency choices, failure recovery, hot-link behavior, privacy and abuse boundaries, and observability.

At the relational-data checkpoint, write SQL for the link with the most upvotes and for the link with the highest net score, with deterministic LinkId tie-breaking.

What to build

  1. Let an authenticated user create a generated short URL that remains associated with that creator and is safe to retry.
  2. Resolve a known short URL to its original destination without depending on voting or ranking availability.
  3. Let a signed-in user create, change, or remove at most one upvote or downvote for each short link without double-counting retries.
  4. Return the current durable upvote, downvote, and net totals on an individual link detail read.
  5. Return deterministic paginated rankings by most upvotes and by highest net score, with projection freshness metadata.

At scale

  • 100 million active links
  • 10 million daily users
  • 100000 peak redirects per second
  • 5000 peak vote writes per second
  • Popularity rankings may lag accepted votes by at most one minute
  • The serving path tolerates a single-zone failure