System Design Notes

vipul pachauri
1 min readMay 17, 2023

--

URL Shortner

Functional Requirements :

  1. Create Short URL for Long URL
  2. Retrieve Long URL from Short URL

Non-functional Requirements:

  1. Traffic : Read Calls -> ~500 TPS, Write Calls -> 100 TPS
  2. Data : short_url,long_url,created_at,expiry_at -> ~ 2KB per transaction

Storage :

  1. For a day : 24 * 60 * 3600 * 500 = ~2.5 M TPD
  2. For a year : 365 * 2.5 = ~912.5 M TPY
  3. Total Data = 1.8 TB in a year
  4. For 10 years -> 18 TB storage capacity

Choose Database : We need high availability and low latency, we can go with NoSQL .i.e MongoDB,Cassandra

How to generate unique short url ?

we need to generate unique id for distributed system. We can go with Token generator or Zookeeper, which will provide range to each application server.

Length of Unique Id and Hash Function ?

Usually, we take 7 chars unique id and we can use Base64 (0–9,a-z,A-Z) or MD5 Hash function to encode.

Collision case ?

It might be possible we can have same unique id for different urls, it is collision. that the reason we are using Zookeeper.

--

--

vipul pachauri
vipul pachauri

Written by vipul pachauri

Senior Software Backend Engineer

No responses yet