EasyFoundationsStorage And Delivery
Design URL Shortener
Build a scalable URL shortening service that supports creation, redirection, caching, and analytics ingestion for a fast user experience.
What to build
- Create a short URL for a valid long URL with optional custom alias, expiration time, and owner metadata.
- Redirect a short URL to the original destination while handling missing, disabled, or expired links.
- Record click events with timestamp, referrer, coarse geography, device type, and short code.
- Expose basic link management for authenticated owners, including list, disable, and update expiration.
Constraints
- Support high read throughput for redirects.
- Keep short URLs available with low latency and cache hit rates.
- Ingest click analytics asynchronously.
Core flows
- Create short URL: Create mapping and optionally cache.
- Redirect short URL: Serve redirect from cache if available.
Quality targets
- Performance: Serve cached redirects with very low latency and keep the redirect path minimal.
- Scalability: Optimize for read-heavy traffic with horizontal stateless services, cache replication, and partitioned storage.
- Availability: Keep redirects available during partial database or analytics pipeline outages.
Operating envelope
Scale targets
- Redirects/secThroughput
- 20,000
- Creates/secThroughput
- 200
- Redirect p95Latency
- < 75ms
- Short linksScale
- 100M
- Analytics lagFreshness
- < 10min
Nudges, not spoilers
Starter hints
Keep redirects thin
PitfallThe redirect path should avoid synchronous analytics writes; resolve, validate, redirect, then emit click events asynchronously.
Short code generation
StarterUse a collision-safe strategy such as random codes with retries or generated IDs encoded into a compact alphabet.
Architecture concepts
Start with these concepts, then connect the request path in the workspace.
ClientAPI GatewayURL ServiceNoSQL DatabaseRedis CacheRate Limiter
Full brief locked
Sign in to see scenarios, rubric, interview prompts, failure modes, and the complete architecture guide.