A URL shortener is a service that converts a long URL into a shorter, more manageable version. These short links typically contain a short domain name and a unique identifier (e.g., bit.ly/abc123) that maps back to the original long URL.

Popular services like TinyURL, Bitly, and t.co (used by Twitter) rely on URL shorteners to:
In this chapter, we will explore the low-level design of an url shortener in detail.
Let's start by clarifying the 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:
Candidate: Should the system automatically generate short URLs, or should users be able to specify custom aliases?
Interviewer: The system should support both. . By default, it should generate a unique short URL automatically, but users can also provide a custom alias if they prefer.
Candidate: Should the short URLs have an expiration policy, or should they remain valid indefinitely?
Interviewer: By default, short URLs should not expire. But we should allow users to specify an expiration date if needed.
Candidate: Do we need to support analytics, like tracking click counts and timestamps?
Interviewer: For now, basic click count tracking will suffice.