echo 1 > /proc/sys/vm/drop_caches a good idea?

Login or Register to Reply

Thread Tools Search this Thread
# 1  
Old 10-15-2010
echo 1 > /proc/sys/vm/drop_caches a good idea?

Hi folks.
I work with several production servers, and I have seen in some Kernel Cache using most of the memory.

See this pic:


Do you think this is a smart choice? Remember these are productions servers and it is extremely necesary this does not cause any issues further.

sync; echo 1 > /proc/sys/vm/drop_caches

# 2  
Old 10-15-2010
What is the value of (your) /proc/sys/vm/drop_caches now?
# 3  
Old 10-15-2010
Hi Neo, thanks for the quick reply, I'm home now, and won't be back in my job until 15 hours, but I will let you know Smilie

---------- Post updated at 06:58 AM ---------- Previous update was at 06:56 AM ----------

by the way swappiness is set to "60" if that helps, and this box is a database server (mysql)

---------- Post updated at 07:00 AM ---------- Previous update was at 06:58 AM ----------

What if the drop_caches was set to "0" ??
# 4  
Old 10-15-2010
Hi Eric,

Actually, it really does not matter much, frankly speaking. I've experimented with dropping caches in Linux so many times on our production web server (LAMP).

Linux does such a great job at using all available memory, and reclaiming it when needed, so it is better to let Linux manage those things.

When you drop the cache (or caches), you will see the CPU load go up (sometimes way up) because the cache is gone. Available RAM goes up, but it does not matter because performance is slower because the cache is empty.

Then over time, if you leave the caches off, the performance will suffer because you are not taking advantage of the cache.

Linux tries to use all available RAM, so the caches will fill over time if you don't instruct Linux to drop the caches, and this is a good thing. You will see available RAM go down, but don't worry, it is available for applications when needed because applications take higher priority than cache.

You want Linux to use all the RAM. That is a good thing because the kernel is basically using all available RAM that is not used by applications (and the OS) for cache. Dropping caches has little positive effect on performance. In fact, it tends to have a negative effect. The reason is that you are not really making more RAM available to the apps, because the apps already have been given the RAM needed. You simply are dropping the cache, which degrades performance.

Regarding, swappiness, the same is basically true. Linux will dump the cache before swapping, as I recall, but I would need to read up on that again to see exactly how it works.

We have experimented with swappiness, and ours is currently set to:
# cat swappiness

... and FYI:

# cat drop_caches

This User Gave Thanks to Neo For This Post:
erick_tuk (10-15-2010)
# 5  
Old 10-15-2010
Unless you're trying to address a performance issue, I'd agree that there's no need to prevent any cache use.

Look at it this way: cached data will be discarded if anything else needs the RAM, and free RAM is wasted RAM.

Seriously: free RAM is wasted RAM.
# 6  
Old 10-15-2010
Copies of disk data pages in RAM can't be a bad thing, as long as they are not 'dirty' (unrepatriated to their media page)! I am amazed it took so long. Is there such a thing as too much RAM, other than to a reliability model?
Login or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug? wisecracker Programming 2 03-07-2017 11:24 AM
Cat /proc/sys/net/ipv4/ip_local_port_range chercheur111 IP Networking 5 11-13-2014 02:58 PM
Drop_caches doesn't work on Solaris but works on RHEL6 Anirudh Kumar Solaris 4 11-05-2014 01:35 PM
Compact script with array - Good idea? Spadez Shell Programming and Scripting 2 07-24-2012 12:29 PM
How to correctly use an echo inside an echo? mokachoka UNIX for Dummies Questions & Answers 3 09-20-2009 12:40 AM
_/proc/stat vs /proc/uptime coderd UNIX for Dummies Questions & Answers 0 05-08-2009 03:37 PM
Kernal panic error& setuproot:error mounting /proc&/sys arjunreddy3 Linux 2 03-10-2009 01:10 AM
any good idea on this? fedora Shell Programming and Scripting 7 09-29-2006 04:36 PM
Echo escaped \c in SH Shell Any Idea asami Shell Programming and Scripting 4 05-04-2006 08:24 AM
Limitations of awk? Good idea? Bad idea? yongho Shell Programming and Scripting 2 06-08-2005 06:18 PM
/proc aojmoj UNIX for Advanced & Expert Users 3 11-20-2002 05:54 PM
about /proc fuqiang1976 UNIX for Dummies Questions & Answers 1 09-10-2001 08:46 AM
Dual Boot a good idea? PravusMentis UNIX for Dummies Questions & Answers 8 07-18-2001 04:02 PM