How to configure a RAM disk on an OVH dedicated server to increase read/write performances
Would you like to boost your server's performance without installing an SSD drive? Consider mounting a RAM disk. Thanks to the increase of memory capacity in servers, there is room to use a chunk of this memory to mount a virtual disk directly in RAM.
What is a RAM disk?
A RAM Disk is a virtual hard drive that uses part of the random access memory (RAM) as a system partition. As such, it appears as just another partition and can be used as a regular partition, only it'll be much faster than a traditional SATA disk.
Why would you want to use this technique? The answer is performance pure and simple. And you can still maintain a SATA hard drive configuration which will provide plenty of storage space. All you need is enough memory to mount a RAM drive partition. The more RAM you have, the bigger the partition and the more temporary files you can store on it.
Bandwidth from RAM to CPU (59.7 GB/s for a E5-1620v2 processor) can also provide a great advantage whereas the SATA connection (maximum bandwidth of the
Bus SATA III: 768 MB/s) can quickly become a bottleneck.
Setting up this type of partition warrants caution nonetheless. We strongly recommend that you only use this type of system for temporary, non critical data. Because RAM is volatile, a server reboot would wipe out all data on the RAM disk.
Cache system (for an application):
Some applications require reading and writing a significant number of temporary files; in such cases, using a RAM Disk can tremendously speed up the writing and processing of those files as well as optimising your application's processing time.
Hosting a high traffic PHP website:
When a PHP website has reached a certain size, a significant number of files can be accessed during requests from visitors. By moving the storage space for those files over to a RAM disk, the site's response time can be optimised.
Game hosting (Minecraft):
On a Minecraft server, limitations are often brought on by I/O operations (read/write). Moving data over to the RAM will result in high speed access times and data transfers.
Configuring and mounting a RAM disk in Ubuntu
Create your directory (you must be root on your server):
root@ns3012742:~# mkdir /media/ramdisk1
verything inside this directory will be stored in RAM.
Define access rights on this partition. Configure chmod when mounting, with the sticky bit, add this line in fstab:
root@ns3012742:~# echo "tmpfs /media/ramdisk1 tmpfs defaults,size=16g,mode=1777 0 0" >> /etc/fstab
The size option lets you set the quantity of memory to be allocated (here we have chosen 16 GB).
Mount the partition. In doing this you can also confirm that the command line for mounting in the fstab is correct:
root@ns3012742:~# mount -a
Make sure that disk was mounted:
root@ns3012742:~# mount |grep ^tmpfs
tmpfs on /media/ramdisk1 type tmpfs (rw,relatime,size=16777216k)
Verify that the access rights are correct:
root@ns3012742:~# ls -la /media/ramdisk1
drwxrwxrwt 2 root root
drwxr-xr-x 4 root root
Your «ramdisk1» has been correctly configured and mounted.
Recommended servers
The MC-128 GAME server
With a high frequency CPU (3.7GHz), 128 GB of RAM and permanently equipped with the Game AntiDDoS, the MC-128 server is suitable for hosting games such as Minecraft or Rust.
The SP-128-S server
The SP-128-S server is perfect for setting up this system; it has 128 GB of RAM and a Xeon E5-1620v2 processor with a maximum bandwidth of 59.7 GB/s.