A modern system design case study for building a scalable URL shortening service like Bitly or TinyURL.
This project focuses on designing a high-performance distributed system capable of handling millions of redirects, analytics events, and URL generations at scale.
URLDN demonstrates the architecture and engineering decisions behind a production-grade URL shortener.
The system supports:
- URL shortening
- Fast redirection
- Analytics tracking
- Distributed scalability
- High availability
- Caching strategies
- Database scaling
Design a URL shortening service that:
- Converts long URLs into short links
- Redirects users efficiently
- Handles massive traffic
- Supports analytics
- Maintains high availability
Example:
Input:
https://www.example.com/blog/how-to-build-distributed-systems
Output:
https://urldn.com/AbX91qKGenerate short URLs from long URLs.
Redirect users instantly to the original URL.
Track:
- Click count
- Country
- Device
- Browser
- Referrer
- Timestamp
Example:
https://urldn.com/github- High scalability
- High availability
- Fault tolerance
- Low latency redirects
- Horizontal scaling
- Reliability
100 million URLs/day
≈ 1157 writes/secAssuming read/write ratio = 10:1
≈ 11,570 reads/secClients
↓
CDN / Cloudflare
↓
Load Balancer
↓
API Servers
↓
Redis Cache
↓
PostgreSQL
↓
Analytics Queue
↓
ClickHousePOST /api/v1/urlsRequest:
{
"longUrl": "https://github.com/lahcenassmira"
}Response:
{
"shortUrl": "https://urldn.com/AbX91qK"
}GET /:shortCodeResponse:
301 Redirect
Location: https://github.com/lahcenassmiraClient Request
↓
Load Balancer
↓
Redis Cache Lookup
↓
Database Fallback
↓
301 / 302 Redirect| Column | Type |
|---|---|
| id | BIGINT |
| short_code | VARCHAR |
| long_url | TEXT |
| created_at | TIMESTAMP |
| Column | Type |
|---|---|
| id | BIGINT |
| short_code | VARCHAR |
| country | VARCHAR |
| browser | VARCHAR |
| clicked_at | TIMESTAMP |
Characters used:
0-9
a-z
A-ZTotal:
62 charactersID: 12581231
↓
Base62: 4Fz91
↓
https://urldn.com/4Fz911. User submits URL
2. Validate URL
3. Generate unique ID
4. Convert ID → Base62
5. Store in database
6. Cache in Redis
7. Return short URLRedis stores:
shortCode → longURLExample:
AbX91qK → https://github.com/lahcenassmiraBenefits:
- Faster redirects
- Reduced database load
- Improved latency
Easy horizontal scaling behind load balancers.
Use read replicas for scaling reads.
Process analytics asynchronously to keep redirects fast.
- Rate limiting
- Spam protection
- DDoS mitigation
- URL validation
- Bot detection
| Layer | Technology |
|---|---|
| Backend | Node.js + Express |
| Database | PostgreSQL |
| Cache | Redis |
| Analytics | ClickHouse |
| Queue | Kafka / RabbitMQ |
| Infrastructure | Docker |
| CDN | Cloudflare |
- Smart redirects
- Geo-routing
- AI analytics
- QR code generation
- Edge redirects
- Link expiration
- Custom domains
URLDN demonstrates the design of a scalable distributed URL shortener capable of handling millions of requests efficiently.
This project explores:
- Distributed systems
- Database scaling
- Caching
- System reliability
- API design
- High-performance architectures
Built for educational and system design learning purposes.