System Design Interview – URL Shortener Service (TinyURL)

Join me to stay up-to-date and get my new articles delivered to your inbox by subscribing here.

January 26, 2023

Distributed Systems  System Design Interview 

Overview

A URL shortener service, such as TinyURL, is a web service that provides short aliases for the redirection of long URLs. For example, the URL “https://example.com/very/long/url” can be shortened to “http://tinyurl.com/abc123”.

System Design

  1. Database Design:

The database should store the following information:

• Original URL: The original long URL that needs to be shortened.
• Short URL: The shortened URL that will be used to redirect to the original URL.
• Creation Date: The date and time when the URL was created.
• Number of Redirects: The number of times the short URL has been used to redirect to the original URL.

  1. API Design:

The API should provide the following endpoints:

• Create: This endpoint should accept a long URL as an input and return a short URL as an output.
• Redirect: This endpoint should accept a short URL as input and redirect the user to the original long URL.

  1. Algorithm Design:

The algorithm should generate a unique short URL for each long URL. This can be done by using a hash function to generate a unique hash for each long URL. The hash can then be used as the short URL.

*** Created by ChatGPT on Jan 26, 2023.