How can I Install OptimumCache on CloudLinux OS

On almost all shared hosting providers, there is one thing in common that all share. They have multiple installations of WordPress, Joomla, Drupal, Wikis, forums, and many other popular CMS software.

We are talking about hundred of the same files installed over and over on different directories on the same operating system. This are duplicate files, that are loaded over and over from your SSD or SATA drives. This generates excessive IO operations and causes servers to be less performant.

OptimumCache is a technology created by the fantastic team of CloudLinux, fixes this by caching all those duplicated files into a new the file system. This leads into faster access to the files, and leveraging disk IO. This improves file read times, reduces memory usage, generates less number of disk operations and improves website speed response time.

On this tutorial we will explore how to install optimumcache on CloudLinux Operating System. Let’s start.

Contents

Install OptimumCache Step by Step

OptimumCache requires CloudLinux 6.x, or higher, Ext4 filesystem to work and kernel lve1.2.55 or higher.

Installing OptimumCache on cPanel

yum install optimumcache

Let’s run the mark option to cache user directories inside /home. If you have other home directory, you can change that.

optimumcache mark --recursive /home_dir

Important: running this command may take very big amount of time, as it scans all user accounts and each subdirectories, it can take hours or days if you have too much information and most if you are using slow drives like SATA or SAS.

This mark process has to be run only once. Once ready, alll new files and subdirectories will be marked to be included in the cache automatically without manual intervention.

On cPanel based servers, you simply type:

optimumcache mark --recursive /home

If you have two /home directories, like /home2 for example, you can mark multiple home directories, example:

optimumcache mark --recursive /home /home2

Open another terminal, and type ‘top -c’ to monitor your server performance at CPU and IO levels, just in case. If you see it overloads your server, then it’s likely you will need to run this on a weekend and over the night, where your server traffic is low.

All cached files will be stored at:

/var/cache/optimumcache

Be aware it will need at least 5GB of free disk space to store all the duplicate files in the cache directory. This 5GB will be used to create the optimumcache ploop, that later will be mounted at /var/cache/optimumcache

Configuring OptimumCache

Once ready, you can tweak and configure optimumcache settings by editing:

/etc/sysconfig/optimumcache

From there you will be able to tweak settings the cache directory, etc.

Once done, you can apply changes by restarting the service:

service optimumcache restart

Be aware of your ploop size

OptimumCache is a file system cache, and in simple words that means you will need to have enough free disk space for this cache system to work properly.

You can check the size of your ploop by checking messages log on your system, for example:

[[email protected]:~]grep OptimumCache /var/log/messages
Jan 4 10:08:43 srv01 optimumcache[308621]: Starting OptimumCache monitor
Jan 4 10:30:05 srv01 optimumcache[308621]: OptimumCache recommends cache storage size to be at least 5.61GB (currently 4.79GB available)
Jan 4 10:31:13 srv01 optimumcache[308621]: OptimumCache recommends cache storage size to be at least 6.49GB (currently 4.79GB available)
Jan 4 10:32:20 srv01 optimumcache[308621]: OptimumCache recommends cache storage size to be at least 6.88GB (currently 4.79GB available)
Jan 4 10:33:27 srv01 optimumcache[308621]: OptimumCache recommends cache storage size to be at least 7.30GB (currently 4.79GB available)
Jan 4 10:37:29 srv01 optimumcache[308621]: OptimumCache recommends cache storage size to be at least 7.52GB (currently 4.79GB available)
Jan 4 10:39:55 srv01 optimumcache[308621]: OptimumCache recommends cache storage size to be at least 7.86GB (currently 4.79GB available)
Jan 4 11:15:21 srv01 optimumcache[403902]: Starting OptimumCache monitor
Jan 4 11:17:31 srv01 optimumcache[403902]: OptimumCache recommends cache storage size to be at least 5.42GB (currently 4.79GB available)
Jan 4 11:19:00 srv01 optimumcache[403902]: Claiming 7.12GB more space than OptimumCache storage size 4.79GB

That’s why, if you need to resize the size of the ploop generated by optimumcache, you can do it by running:

occtl --resize-ploop 5G

or

occtl --resize-ploop 4G

How can I check OptimumCache is working?

After you marked your user directories and generated the ploop image it will be mounted automatically, you should see a new partition like this:

[[email protected]:~]df -ah | grep optimum
/var/share/optimumcache/DiskDescriptor.xml  4.8G  4.6G  6.4M 100% /var/cache/optimumcache

You can also check OptimumCache stats by running:

[[email protected]:~]optimumcache stat
csums:      533763 (76.8%)
           fetched   uncached     cached percentage  de-duplication coefficient (effective)
inodes:     695423     527472     167951      24.2%                       16.0%
size,kB:  56510341   53031896    3478445       6.2%                        3.1%
RAM,kB:    8613748    8563752      49996       0.6%                        0.1%

Suggested reading: How to read OptimumCache Stats

You can also check if the OptimumCache service is running

service optimumcache status

Output example:

[[email protected]:~]service optimumcache status
optimumcache_s (pid 891519) is running...

Conclusion

That’s all. Now you know how to install OptimumCache, it should be installed and working, which will be traduced in overall better speed for your web apps and server resource usage. However, be aware of the ploop size on a low resource VPS with little to nothing available disk space.

Further reading:

About the Author: Martin Keler

Leave a Reply

Your email address will not be published. Required fields are marked *