Design URL Shortener
Programming Interview
Medium
3 views
Problem Description
Design a URL shortener like bit.ly. Focus on APIs, storage, and scaling.
Official Solution
API: POST /shorten(longUrl), GET /{code}. Store mapping code->longUrl with createdAt and optional expiry. Generate codes with a monotonically increasing ID + base62. Cache hot mappings in Redis. Use redirects (301/302). For scale: partition by code prefix, add read replicas, and run analytics asynchronously.
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!