A high-throughput URL shortening service (similar to Bitly) built to demonstrate modern backend System Design principles.
Although conceptually simple, this project implements a production-style architecture optimized for read-heavy workloads using an in-memory caching strategy to significantly reduce database latency.
- Unique short URL generation
- Redis-based caching using the Cache-Aside pattern
- TTL-based automatic cache expiration
- RESTful API with interactive Swagger documentation
- Fully containerized using Docker Compose
- Optimized for low-latency redirection
Built with FastAPI for asynchronous and high-performance request handling.
SQLite / PostgreSQL used for durable, ACID-compliant URL storage.
Redis is used as an in-memory caching layer.
Mechanism: Cache-Aside Pattern
- On request → Check Redis
- On cache miss → Query database
- Store result in Redis with TTL
- Subsequent requests served from memory
This reduces disk-based database access to constant-time in-memory retrieval for frequent reads.
Application and Redis services are orchestrated using Docker Compose.
Client
↓
FastAPI
↓
Redis (Cache)
↓ (on miss)
Database
- Clone the repository:
git clone https://github.com/yourusername/url-shortener-redis.git cd url-shortener-redis