Virtual Instances on Bad Quality Hardware Can Die Instead of Performance Boost. We Can Mount wp-content Directory into RAM Memory For Testing. This is quite advanced guide and despite it appears easy, you should take precautions (server snapshot) and know something about recovery. We will mount wp-content directory slow PHP dragged WordPress into RAM Memory sounds so inviting that it is difficult not to do the thing.
Mount wp-content Directory into RAM Memory : Understand Mounting
We described how to mount swap space on virtual instance. The basic commands are quite closer and our method has basic advantages : Everything will comeback to the previous state if you just reboot.
Mount wp-content Directory into RAM Memory (HP Cloud, Nginx)
This is popularly known as creating a RAM directory to serve the static cache files and HTML files. Take that we have nginx installed and public FTP root is at
/usr/share/nginx/html. First shut down nginx :
service nginx stop
proxy_cache_path is set to
/usr/share/nginx/cache/fcgi, then run these two commands :
mount -t tmpfs -o size=1G tmpfs /usr/share/nginx/html/wp-content/cache
mount -t tmpfs -o size=1G tmpfs /usr/share/nginx/cache/fcgi
Start nginx now :
service nginx start
Just like adding swap tutorial, if you want the wp-content to remain even after a reboot (you are not doing this step before testing the above), then edit
/etc/fstab and add this line for the above case :
tmpfs /usr/share/nginx/html/wp-content/cache tmpfs defaults,size=1G 0 0
The above is permanent method. You can run
df -ah | grep tmpfs or
df -k command to check the things. We have taken the screenshot on test server – the screenshot is not of live instance. You should be careful about what you are doing. We are using tmpfs. Both the rams and tmpfs does the same thing with some differences. tmpfs uses swap but ramfs does not use swap. ramfs on physical server is really fast.
We do not recommend to use these on cloud server instances. From our testings, these give inconsistent results. All is basically getting allocated from the disk, so practically the gain is very low on virtual instances.
Follow the Author of this article :