Virtualbox shared folders much faster then samba for Railo + Nginx

  Follow me: Follow Bruce Kirkpatrick by email subscription Bruce Kirkpatrick on Twitter Bruce Kirkpatrick on Facebook
Thu, Jul 11, 2013 at 2:40AM

It seems virtualbox configuration needs to be just right for good performance when the web application's source code is stored outside the virtual machine.  I figured out that virtio nic type (Virtualbox network adapter paravirtualized network) and shared folders are much faster then choosing another nic type and using samba.  In the past, I had issues with Virtualbox shared folders not updating cached info on source code files quickly enough.  Maybe they have improved it or maybe I just read the manual better now.  

I found there is a "ttl" (time to live) mount option.  I set mine to ttl=1, so it will hopefully only cache file info for 1 second.  I think virtualbox must be hanging/pausing when there is a lot of samba I/O, but it runs close to native speed with shared folders for operations that used to take 5 to 10 times longer to execute.  The system also boots up much faster.
After setting up a shared folder in virtualbox and clicking "make permanent", you can add it in /etc/fstab in linux to auto-mount it at boot.  Here is the command I used to mount a shared folder named "vhosts" to /opt/vhosts on the guest.
vhosts /opt/vhosts  vboxsf    uid=nginx,gid=nginx,ttl=1,dmode=0770,fmode=0660         0   0
The manual says ttl = "time to live for dentry", which meant nothing to me. Then I looked up the definition of dentry, and saw it is essentially the filesystem metadata cache stuff that you are setting to expire faster or slower.  This should prevent any issues I was having with updating source code and not seeing it change right away.
FYI: The samba mount was configured like this, and while it works the same way, it is much slower:
//hostsystem/vhosts   /opt/vhosts   cifs   uid=nginx,gid=nginx,file_mode=0660,dir_mode=0770,rw,noserverino,nounix   0 0
The host system is windows 8 pro and the virtualbox guest is ubuntu 13.04.  I also had this problem with Centos 6 as well and I assume it would also be faster when configured like this.

Bookmark & Share

Popular tags on this blog

Performance |