Software Development

What is the best cache eviction policy to minimize database traffic?

CH Asked by Cheryl Higgins · 04-06-2025
0 upvotes 5,140 views 0 comments
The question

We are designing a distributed system and want to use to lower our database operations. Since our memory capacity is limited, what eviction policy (like LRU, LFU, or FIFO) is best suited to keep the most relevant data in memory and maximize our database offloading efficiency?

3 answers

0
TH
Answered on 05-06-2025

For most standard web applications, Least Recently Used (LRU) is the optimal choice for reducing database load. It automatically discards the least accessed items when the memory limit is reached, ensuring that your hot data paths remain readily accessible in memory. If your traffic pattern involves specific items being accessed repeatedly over long periods, Least Frequently Used (LFU) can prevent the database from being re-queried for those core assets, thereby preserving database performance over time.

0
PH
Answered on 15-07-2025

LRU is great, but what happens when a batch script or web crawler sweeps through your data, pulling old records that haven't been accessed in months? Won't that pollute your layer and evict all your actual hot data, causing a massive database spike right after?

BR 17-07-2025

To safeguard against that, you should look into an LRU-2 or 2Q policy. These advanced algorithms require an item to be accessed twice before it gets promoted to the main cache tier, successfully filtering out one-off scan pollutions from automated scripts.

0
PA
Answered on 30-09-2025

LRU is generally the safest baseline because web traffic naturally follows a Zipfian distribution where recent items are requested most.

CH 01-10-2025

Completely true, Patrick. Sticking with LRU handles standard user behavior perfectly without introducing unnecessary complexity to your infrastructure code.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session