BeginnerRedis
The product cache outgrows its memory
A Redis cache with the default eviction policy meets a catalog three times bigger.
The setup today
Product pages are cached in a single Redis instance using cache-aside: on a miss the app reads the database and stores the rendered page. The database is the source of truth, so losing a cached page only costs one slower request. Nobody changed the Redis defaults apart from the memory limit.
Current configuration
maxmemory 4gb
maxmemory-policy noeviction # the default
# cache keys are written with SET, no TTL
appendonly noWhat you know
- The cache holds about 3 GB today.
- The machine has 8 GB of RAM.
- About 20% of products receive 80% of page views.
The new requirement
The catalog is growing from 400,000 to 1.2 million products next month, and marketing wants every product page to stay fast. At the current size per page, caching everything would need about 9 GB.
Make the call
2 questions · first-try answers earn the most XP
What a strong answer also covers
- Keep maxmemory below physical RAM so the operating system and any background save have headroom.
- Add a TTL to cached pages anyway, so a price change reaches readers even if invalidation has a bug.
- Expect a burst of misses (and database load) right after a deploy that changes the page format; version the keys.
- Estimate first: if the hot 20% is about 2.4 GB, 4 GB with LFU should hold it comfortably.