RootConsole.net

advices, tips, blog

  • Home

How to flush cache on Linux?

Posted by Admin on November 20, 2017
Posted in: Servers, Shell.

Sometimes (especially when system works on heavy load) Linux buffers and caches contains a lot of objects. This behaviour is generally highly desirable but let’s take a look at following scenario.

Web server is a victim of a DDoS attack. Most of free RAM is used by caches. DDoS has ended and we quickly need to free some RAM for our main application and database system. Cache will warm-up again but it take some time. We need to initiate cache warm-up now!

Linux kernel offers easy to use mechanism for Virtual Memory and Cache management. It’s functions are available by /proc. To free slab objects (dentries and inodes) and pagecache use this command:

# echo 3 > /proc/sys/vm/drop_caches

Cache dropping is more effective when you force sync just before cache drop.

# sync && echo 3 > /proc/sys/vm/drop_caches

Now you have significantly more free RAM. As an optional task you can free system swap (turn off swap and turn it on again). After this operation you should notice better system performance (after cache warm-up).

Posts navigation

← How to enable EPEL repository in CentOS 7?
How to save Screen layout? →
  • or
    BTC
    1BLAWYYBP9ZGUwsJigtqW7JWLoaFFfZhMp
  • Contact

Proudly powered by WordPress Theme: Parament by Automattic.