AlgoMaster Logo

Design URL Shortener

High Prioritymedium22 min readUpdated June 27, 2026
Practice this Problem

In this chapter, we will explore the low-level design of an url shortener in detail.

Let's start by clarifying the requirements:

1. Clarifying Requirements

Before starting the design, it's important to ask thoughtful questions to uncover hidden assumptions, clarify ambiguities, and define the system's scope more precisely.

Here is an example of how a conversation between the candidate and the interviewer might unfold:

Functional Requirements
  • Automatically generate a unique short URL for any given long URL
  • Allow users to optionally specify a custom alias for the short URL
  • Allow users to define optional expiration dates for short URLs
  • Redirect users to the original long URL when the short URL is accessed
  • Handle URL conflicts gracefully (e.g., when a custom alias is already taken)
  • Track and store the number of times a short URL has been visited
Non-Functional Requirements
  • Uniqueness: Each short URL (including custom aliases) must be unique across the system
  • Extensibility: The design should be flexible enough to support future enhancements
  • Maintainability: Code should follow object-oriented principles, with clean abstractions and clear separation of concerns

Two of these requirements, custom aliases and expiration dates, are layered onto the core design rather than built into it from the first pass. The base design focuses on automatic key generation, deduplication, and click tracking, and section 7 shows how aliases and expiration slot in without changing that core.

Keeping the first version small makes the design easier to follow, and it doubles as a test of whether the abstractions hold up when requirements grow.

With the requirements settled, the next step is to identify the core entities and the algorithm that will power our design.

2. Identifying Core Entities

Premium Content

This content is for premium members only.