High-Throughput REST API Platform
E-commerce platform hitting database bottlenecks at 500+ concurrent users. Response times exceeding 2s for product listing endpoints.
Redesigned data access layer with Redis caching, connection pooling, and read replicas. Implemented CQRS pattern to separate read/write paths.
Redis was chosen over Memcached for its data structure support. CQRS allowed independent scaling of read-heavy workloads without affecting write throughput.
Response time dropped from 2.1s → 180ms. Handled 5,000+ concurrent users. 99.9% uptime over 6 months.
// Cache-aside pattern
router.get("/products", async (req, res) => {
const cacheKey = `products:${req.query.page}`;
const cached = await redis.get(cacheKey);
if (cached) {
return res.json(JSON.parse(cached));
}
const data = await db.query(
"SELECT * FROM products LIMIT $1 OFFSET $2",
[limit, offset]
);
await redis.setex(cacheKey, 300, JSON.stringify(data));
res.json(data);
});