Using RAM Cache to Speed Up Linux Disk Performance


In some cases the capacity of hard disks is sufficient to meet the storage demands, however, in many cases we need to have both large storage capacity and high performance.

Half Term

It is not always possible to do the necessary investments to achieve the desired performance, in line with storage capacity. This is especially true in times of IT crisis, where we need to solve a problem in the shortest possible time.

Cache for Performance

For a personal project, I developed a Tuned profile that instructs the Linux Kernel to utilize a large amount of RAM for disk storage caching. This culminated in expressive reading and writing performance results (around 900Mbps). Take a look at the image below.

  • Image captured from a Xeon 2620v3 with 32GB DDR4 and SATA Disks.
Diskcache Tuned Profile


Despite the good result, this type of Kernel adjustment comes with some risks. For example, while the data is cached, the environment needs to stay powered on. A sudden power outage will result in the loss of data that has not yet been effectively written to disk.

Where to Use

This Tuned profile is recommended for any high performance data access need (as long as the environment is controlled), such as:

  • File Servers
  • Database Clusters
  • Elasticsearch Clusters
  • Log Storage Clusters
  • Anything that intensively read files
Example of a fault-resilient DB architecture
  • Use a single node for INSERTS and UPDATES, and the other nodes for queries.

Tuned Profile

I’m not going to teach you how to profile tuned (you can google this). So, I will only present the profile contents.

  • Explanations are in the file itself, and in this link.
# tuned configuration

summary=Maximize RAM usage for disk operations

# tell the kernel to use up to 99% of the RAM as cache for writes and instruct kernel to use up to 50% of RAM before slowing down the process that's writing (default for dirty_background_ratio is 10).
vm.dirty_ratio = 99

# Start background writeback (via writeback threads) at this percentage
vm.dirty_background_ratio = 50

# And tell that 1h write delay is ok to even start writing stuff on the disk (again, I recommend caution):
vm.dirty_expire_centisecs = 360000
vm.dirty_writeback_centisecs = 360000

# vfs_cache_pressure at 2000 causes that most of computing happens in the RAM and very late disk writes.
vm.vfs_cache_pressure = 2000

Use With Moderation

Always keep in mind the risks of using this Tuned profile. Special consideration should be made before putting something like this into production environments.

Full Cache Disk Sync


I hope this technique can help you out of a crisis situation. If you have any suggestions or questions, send me a message.

Sonic :-)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andre Rocha

Andre Rocha


I'm just a SysAdmin with some experience in OpenSource, DevOps and Datacenter Services, who likes to share knowledge.