GoogleHardSystem Design
Design a URL Shortener
Backend Engineer
Problem
Design a scalable URL shortening service similar to Bitly or TinyURL.
Example
Input:
https://example.com/very/long/url
Output:
https://short.ly/abc123
Approach
Design an API for creating and resolving short URLs. Store short-code mappings in a database and add caching for frequently accessed URLs.
Complexity
Time: O(1) for get and put
Space: O(capacity)
Solution
Core components:
1. API Gateway
2. URL shortening service
3. Key generation service
4. Database
5. Redis cache
6. Load balancer
Related Topics
Hash MapLinked ListDesign