Sitemap
Developers Keep Learning

Welcome to Keep Learning, an inspiring online publication created by developers, for developers.

How to design a URL Shortener?

3 min readDec 25, 2022

--

These are my notes about how to design a URL shortener.

What is a URL Shortener Service?

  • It is for generating shorter aliases for long URLs.
  • Common system interview question

Imagine you have an URL like this;

https://www.example.com/ex/testtestestest1.php?a=5&b=4

You will convert to like

https://shorturl.com/y73g2zjl

What are the Requirements

  • 1 million URLs are generated per day
  • URLs are the combination of [0–9] [a-z, A-Z]
  • Generate possibly the shortenest version

Back-of-the-envelope estimation

  • Write per second: 1 million / 24 / 3600 = 12
  • Read per second: 12 * 10 = 120 (Assuming 10:1)
  • After 10 years: 1 million * 365 * 10 = 3.6 billion (3.650.000.000)
  • Assume the average URL length is 100 bytes.
  • After 10 years: 3.6 billion * 100 bytes = 339.93 Gigabytes

Creating High-Level Design

  • We need basically two endpoints. One is for creating a short URL and one is for redirecting to the long version of the URL.

Example Routes

--

--

Developers Keep Learning
Developers Keep Learning

Published in Developers Keep Learning

Welcome to Keep Learning, an inspiring online publication created by developers, for developers.

Atakan Demircioğlu
Atakan Demircioğlu

Written by Atakan Demircioğlu

Passionate about blogging and sharing insights on tech, web development, and beyond. Join me on this digital journey! 🚀

Responses (4)