How I used Redis caching to reduce MongoDB read load by 80% on Srimaccafes, cutting average API response time from 240ms to 12ms.
Srimaccafes was experiencing growing read load on the product catalog API. During peak hours, each product listing request would trigger 3-5 MongoDB queries — one for the product, one for the category, one for the inventory count. At 200 concurrent users, this resulted in an average response time of 240ms and noticeable UI jank on the storefront.
The product catalog is read-heavy and update-sparse. Products are updated by an admin at most a few times per day, but they are read by hundreds of customers continuously. This is the textbook use case for a read-through cache. Redis was chosen for its sub-millisecond latency, built-in TTL support for automatic cache expiry, and its first-class support in Node.js via the ioredis client.
We implemented a Cache-Aside (Lazy Loading) pattern. On a cache miss, the API queries MongoDB, stores the result in Redis with a 5-minute TTL, and returns the data. On subsequent requests within the TTL, the data is served directly from Redis. For the admin panel's write operations, a Cache Write-Through pattern was used — updating MongoDB and the Redis cache simultaneously to prevent stale reads.
API response time dropped from 240ms → 12ms (95th percentile)
MongoDB read operations reduced by 80% during peak hours
System successfully handled a 10x traffic surge during a promotional campaign
Zero stale cache incidents in production since launch