echo 1 > /proc/sys/vm/drop_caches a good idea? | Unix Linux Forums | UNIX for Advanced & Expert Users

  Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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

UNIX for Advanced & Expert Users


Tags
drop_caches, linux, swappiness

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-15-2010
erick_tuk erick_tuk is offline
Registered User
 
Join Date: Oct 2010
Last Activity: 1 April 2012, 9:16 PM EDT
Posts: 23
Thanks: 6
Thanked 0 Times in 0 Posts
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.


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

Sponsored Links
    #2  
Old 10-15-2010
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 28 July 2014, 12:25 AM EDT
Location: Asia pacific region
Posts: 12,995
Thanks: 515
Thanked 868 Times in 397 Posts
What is the value of (your) /proc/sys/vm/drop_caches now?
Sponsored Links
    #3  
Old 10-15-2010
erick_tuk erick_tuk is offline
Registered User
 
Join Date: Oct 2010
Last Activity: 1 April 2012, 9:16 PM EDT
Posts: 23
Thanks: 6
Thanked 0 Times in 0 Posts
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

---------- 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
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
 
Join Date: Sep 2000
Last Activity: 28 July 2014, 12:25 AM EDT
Location: Asia pacific region
Posts: 12,995
Thanks: 515
Thanked 868 Times in 397 Posts
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:

Code:
# cat swappiness
20

... and FYI:


Code:
# cat drop_caches
0

The Following User Says Thank You to Neo For This Useful Post:
erick_tuk (10-15-2010)
Sponsored Links
    #5  
Old 10-15-2010
achenle achenle is offline
Registered User
 
Join Date: Jun 2009
Last Activity: 27 July 2014, 8:40 PM EDT
Posts: 604
Thanks: 1
Thanked 78 Times in 74 Posts
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.
Sponsored Links
    #6  
Old 10-15-2010
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 8 July 2014, 12:19 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,378
Thanks: 8
Thanked 535 Times in 514 Posts
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?
Sponsored Links
    #7  
Old 10-15-2010
erick_tuk erick_tuk is offline
Registered User
 
Join Date: Oct 2010
Last Activity: 1 April 2012, 9:16 PM EDT
Posts: 23
Thanks: 6
Thanked 0 Times in 0 Posts
thanks a lot guys!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
any good idea on this? fedora Shell Programming and Scripting 7 09-29-2006 03:36 PM
Echo escaped \c in SH Shell Any Idea asami Shell Programming and Scripting 4 05-04-2006 07:24 AM
Limitations of awk? Good idea? Bad idea? yongho Shell Programming and Scripting 2 06-08-2005 05:18 PM
Dual Boot a good idea? PravusMentis UNIX for Dummies Questions & Answers 8 07-18-2001 03:02 PM



All times are GMT -4. The time now is 02:15 AM.