URL SHORTENER
REDIRECT
TOKEN EXPIRATION
API
Scalability
Reliability
Performance
Storage
Security
Application should be able to handle 20,000 read requests per seconds while managing 200 write requests per second
Amount of Read request per Day:
20000 * 86400(amount of seconds in the day) = 1,728,000,000 Read requests
Amount of Read request per Month would be around 51 Billions Read request
Amount of Write request per Day:
200 * 86400(amount of seconds in the day) = 17,280,000 Write requests
Amount of Request per Month would be around 510 Millions Read requests
POST /api/shorten : This is the API that accepts the original URL, service will generate a hash, this hash will be appended to the URL and the shortened URL will be returned.
GET /api/redirect/(short_url) : This is the API that will accept the short URL and redirect to the original URL
Since this data store has the core functionality of storing key value pairs with long URL associated with short URL for redirection. Since how read/write request ratio is 100:1 its better to focus on optimizing the read request. Hence this architecture doesn't require relational modal so we'll opt for a Nosql Solution implemented using DynamoDB or MongoDB
Client Request Initiation
API Gateway Processing
Load Balancer Routing
Server Processing
Data Handling & Processing
Database Replication
Redirection & Logging
Response Handling
A load balancer distributes client requests across multiple backend servers to prevent a single server from becoming overloaded. It operates at different layers:
Horizontal Scaling (Adding More Servers) – As traffic increases, more servers are added behind the load balancer.
Auto-Scaling with Cloud Services – Services like AWS ELB integrate with Auto Scaling Groups (ASGs) to spin up/down instances dynamically.
A cache stores frequently accessed data in-memory to reduce database queries and improve response time. Your system likely uses Redis or Memcached for this purpose.
Horizontal Scaling – Distributed caching via Redis Cluster or Memcached shards.
Why LRU?
How LRU Works:
Single Point of Failure at the API ENDPOINT ,we should decentralize operation at this level, allowing API to be more scalable and be fault tolerant by using Horizontal scaling
Load Balancer – If it fails, all requests are blocked.
API Gateway – A failure here prevents requests from reaching backend services.
Database – A failure can cause system-wide data unavailability.
Implement Load Balancer Redundancy to avoid failure at the entry point.
Optimize API Gateway Performance using rate limiting & autoscaling.
Ensure Database Scaling with replication, sharding, and connection pooling.
Use Distributed Caching to reduce direct DB queries.
Optimize WebSocket Connections with message brokers.
Implement Asynchronous Logging to avoid slowing down requests.
Deploy Redundant Redirection Services to ensure high availability.