Running drop_caches daily on production server

caisc

Well-Known Member
Oct 5, 2011
73
2
58
India
cPanel Access Level
Root Administrator
Hi,

Is it good idea to run drop_caches on a production server daily via cronjob in off peak hours?

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

I understand that it will clean up all cache but the free memory will speed up things and overall performance of server.

What do experts say about this

Thanks
 

JacobPerkins

Well-Known Member
May 2, 2014
617
97
103
cPanel Access Level
DataCenter Provider
Twitter
No, this is not wise. You're basically dropping everything from the memory cache. Linux keeps the caches full 99% of the time so it doesn't have to keep reading the disk.

Having 'free' memory will not speed up performance, it will actually make it worse because the kernel will have to read the disk now for things that you've dropped from the caches.

Help! Linux ate my RAM!
 
  • Like
Reactions: eva2000

caisc

Well-Known Member
Oct 5, 2011
73
2
58
India
cPanel Access Level
Root Administrator
Apart from increased Disk usage is there any other drawback? I use SSD on my server so dont think it will be a issue for me.

@cPJacob why I asked this -

I have noticed that by default 99% RAM is utilised by Linux, now with RAM filled up with cache suppose I need to restart CXS scanner that will watch all the accounts on server one by one. with cache in ram this process sometimes takes 6 hours.

Now If I clear cache and restart CXS it completes same task in 30 mins.

CXS watch cycle is a resource intensive process and if it goes on for 6 hours its further slow down the server, so I think its better complete the task quickly and let RAM fill up again with cache in due process.

Having SSD very much compensates the increased disk I/O

What do you say?
 

dalem

Well-Known Member
PartnerNOC
Oct 24, 2003
2,983
157
368
SLC
cPanel Access Level
DataCenter Provider
the draw back is you will wear out your disk faster
But you are probably doing it anyway running csx.


I would suspect that you do not have enough free ram to run csx and its using the swap
since you said 99% is cached



I don't use csx so I do not know ho much memory its uses
But its cousin maldet uses about 200M- 800M with Clamscan

if you could add more Ram so you have plenty free
the slow scan time would go away