System Design — Tiny URL

Dingding Wang
5 min readSep 21, 2019

Product Requirements

P1: Create short URL with full URL as input.

P1: Get/Redirect to full URL with short URL as input.

P2: Short URL expiration time.

Non-product Requirements

P1: Performant — short URL should be as fast as full URL, which means look up and redirect time should be seamless.

P1: Highly available — otherwise all redirects would fail.

Interface/API

Interface 1: create_short_url(full_url, expiration_time)

  • Restrict full_url length with some frontend validation (typically within 500 chars)
  • Expiration time could enum

Interface 2: get_full_url / redirect(short_url)

Algorithm/Architecture

Simplest architecture: we have a dedicated service generating short url, either by hashing full url or some other ways. And we have a persistent storage to store short url look up table.

Since short url records are unrelated to each other, and our system is record heavy, read heavy (described in next section), it makes sense to use NoSQL (Cassandra, DynamoDB, etc).

Create short url flow:

--

--

Dingding Wang

Former Yelper, now a Snapchatter. Focus on Payment transaction system, Search system, Web API server and Internationalization.