3 Vagrant settings you should check out to optimize your VM.

About a month ago I started switching my local environment to a Vagrant VM. ( I know im pretty late. ) Im still a vagrant noob but there are 3 things i've learned so far.

Use NFS ( Network File System )

The default synced_folder driver (VirtualBox) works well until you start importing a bigger project. If you have more than about 100 files the performance is going suck.

But there is a solution!

By simply configuring the synced folder to NFS you get again the wanted performance.

# Synced Folder
# --------------------
config.vm.synced_folder "www", "/var/www", type: "nfs"  

Enable NAT hosts DNS resolver

If you start working on somthing that will do HTTP request you are going to notice that the requests take pretty long. Well as seen Here enabling natdnshostresolver1 and natdnsproxy1 will give you a boost on your networking performance.

config.vm.provider "virtualbox" do |v|  
   v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
   v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end  

Reduce the time sync threshold

After working with an Amazon API I ran into an error that told me the servers and clients date where to diffrent. I checked my VMs date and yep it was about 2 hours late. After a short search I found out that also this problem is easy to solve by reducing the time sync threshold to 10 seconds.

config.vm.provider :virtualbox do |v|  
    v.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000 ]
end  
Mario Döring

Mario Döring

http://clancats.ch

Software Engineer, ClanCats Dude, cineman.ch Developer and general Idiot.

View Comments
Navigation