Improve Magento’s speed using RAM drives
Wikipedia explains very well what RAM drives are and we all know that SSD are fast reading but have issues with endurance
There’s a myriad of options and possibilities that one could do to improve Magento’s performance and adding a different one to the mix doesn’t really hurt, right?
In all systems (confirmation required) you can use /dev/shm, this example is mainly if you want to keep your data separated and mounted in a specific place or give your mount point an specific name.
If anything using /dev/shm is recommended but keep in mind that you’d have to mount it the same way for Magento to use it as it will search for the var directory.
Let’s get down to it, I am using FreeBSD now so let’s start the experiment with it:
FreeBSD, this requires sudo:
/sbin/mdmfs -M -S -o async -s 4096m md0 magento_var_folder_path /bin/chmod 777 magento_var_folder
To remove the mount:
/sbin/umount -f magento_var_folder_path /sbin/mdconfig -d -u 0
So in my case I just did the following:
cd /usr/home/ltineo/www/m/mage sudo mdmfs -M -S -o async -s 4096m md0 var sudo chmod 777 var
The Syntax for Ubuntu:
$ sudo mount -t tmpfs -o size=512M,mode=777 tmpfs magento_var_folder_path
My computer setup:
OS: FreeBSD 9.1 WebServer: Apache 2.2 Database Server: Mysql 5.5 Memcache: no Memory: 12GB of Ram CPU: I7 @ 3.4GHz Architecture: 64bits Solr: enabled Magento: Enterprise 126.96.36.199 Local modules: No Caching: Regular and FPC enabled
So why whould you bother doing this, if the cache will be volatile and upon reboot you are starting up in cold?
Let’s take a look at the numbers:
The siege file can be found here http://pastebin.com/RaJKCxf1
siege -t1m -c100 -b -i -f mage.dev.siege
Transactions: 102 hits Availability: 53.12 % Elapsed time: 59.38 secs Data transferred: 6.23 MB Response time: 9.99 secs Transaction rate: 1.72 trans/sec Throughput: 0.10 MB/sec Concurrency: 17.17 Successful transactions: 102 Failed transactions: 90 Longest transaction: 30.30 Shortest transaction: 0.00
Transactions: 914 hits Availability: 100.00 % Elapsed time: 59.25 secs Data transferred: 58.18 MB Response time: 6.04 secs Transaction rate: 15.43 trans/sec Throughput: 0.98 MB/sec Concurrency: 93.17 Successful transactions: 914 Failed transactions: 0 Longest transaction: 28.76 Shortest transaction: 0.05
Transactions: 798 hits Availability: 100.00 % Elapsed time: 59.23 secs Data transferred: 50.52 MB Response time: 6.90 secs Transaction rate: 13.47 trans/sec Throughput: 0.85 MB/sec Concurrency: 93.01 Successful transactions: 798 Failed transactions: 0 Longest transaction: 23.83 Shortest transaction: 0.18
Transactions: 940 hits Availability: 100.00 % Elapsed time: 59.78 secs Data transferred: 61.33 MB Response time: 5.93 secs Transaction rate: 15.72 trans/sec Throughput: 1.03 MB/sec Concurrency: 93.19 Successful transactions: 940 Failed transactions: 0 Longest transaction: 18.66 Shortest transaction: 0.15
So as you can see running Magento on cold on a RAM drive was almost as good as running it on a cached regular drive.
Of course I’d never suggest to use this over something like REDIS but if you have a load balancer using a NFS RAM Drive share might not be a bad idea if you are using Memcache.
The main benefit of course is that the longest transaction on the ram drive without cache is shorter than the longest transaction on a regular drive with cache enabled by a lot!
Granted it would be a good idea to further this research with a more robust test for to obtain both qualitative and quantitative results