0
0
HLDsystem_design~12 mins

First design walkthrough (URL shortener) in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - First design walkthrough (URL shortener)

This system creates short, easy-to-share links that redirect to long URLs. It must handle many users, provide fast redirects, and ensure short links are unique and reliable.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
URL Shortener Service
  |           |
  v           v
Cache       Database
Components
User
client
Sends requests to shorten URLs or access short links
Load Balancer
load_balancer
Distributes incoming user requests evenly to API Gateway instances
API Gateway
api_gateway
Handles routing, authentication, and request validation
URL Shortener Service
service
Generates short URLs, stores mappings, and handles redirects
Cache
cache
Stores frequently accessed short URL mappings for fast redirects
Database
database
Stores persistent mapping of short URLs to original long URLs
Request Flow - 11 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayURL Shortener Service
URL Shortener ServiceCache
CacheURL Shortener Service
URL Shortener ServiceDatabase
DatabaseURL Shortener Service
URL Shortener ServiceCache
URL Shortener ServiceAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Database
Impact:New short URLs cannot be created and cache misses cannot be resolved, but cached redirects still work
Mitigation:Use database replication and failover to maintain availability; rely on cache for read requests during failure
Architecture Quiz - 3 Questions
Test your understanding
Which component ensures user requests are distributed evenly to prevent overload?
ALoad Balancer
BCache
CAPI Gateway
DDatabase
Design Principle
This design uses caching to speed up frequent redirects and a load balancer to handle many users. The database stores permanent mappings, while the API Gateway manages requests. This separation improves scalability and reliability.