Step 1: Requirements
Requirements
Questions to ask the interviewer
- What is the expected scale? (reads vs writes ratio)
- Do we need custom aliases (e.g.
short.ly/my-brand)?
- Should short URLs expire (TTL)?
- Do we need click analytics (who clicked, when, from where)?
- Is there a character limit on the short code?
- Do we need to handle duplicate long URLs (return the same short URL)?
Functional requirements
- Given a long URL, generate a unique short URL
- Given a short URL, redirect to the original long URL
- Support custom aliases
- Support optional expiration (TTL)
- Track click analytics (timestamp, referrer, user-agent)
Non-functional requirements
- Read-heavy (100:1 read-to-write ratio)
- Low latency redirects (< 50ms)
- Short codes should be URL-safe and compact (6-8 chars)
- High availability — redirects must not fail