Loading...
POST /shorten
{ long_url, custom_alias?, expires_at? }
→ { short_url }
GET /{short_code}
→ 302 redirect
Client
|
CDN
|
API Gateway (LB, rate limit)
|
+----------------------+
| |
Shorten Service Redirect Service
| |
ID Generator Cache (Redis)
| |
+---------> Database (sharded)
Analytics: Kafka → OLAP DB
short_codeurls(
id BIGINT PK,
short_code VARCHAR UNIQUE,
long_url TEXT,
created_at,
expires_at
)
short_codehash(short_code) % Nshort_codelong_url
Write:
→ DB only
Read:
→ Cache miss → DB → populate cache
CDN (edge cache)
L1: in-memory cache
L2: Redis
DB fallback
Return 302
Validate URL
Generate ID
Encode Base62
Store DB
Return short URL