Developing and testing changes in an environment that is the same as the deployment environment is one of the magic ingredients of the DevOps way. For engineers at Tasktop working on the Integration Factory, provisioning a new VM can occur multiple times in a day, so any inefficiencies in the process are painful. I recently stumbled across vagrant-cachier which reduces network usage and speeds up local Vagrant-based provisioning, drastically improving VM provisioning times.
Install vagrant-cachier as follows:
$ vagrant plugin install vagrant-cachier
Then add the following to your ~/.vagrant.d/Vagrantfile
Vagrant.configure("2") do |config| if Vagrant.has_plugin?("vagrant-cachier") config.cache.scope = :box end end
That’s all! The next time you provision a VM using Vagrant, you should see a local cache being created under ~/.vagrant.d/cache
As you can see, vagrant-cachier creates a local cache of dependencies including those provided by apt-get, chef, and of course anything under /var/cache.
This technique is especially helpful for remote developers who are not on 100GB Ethernet to servers hosting VM dependencies.
It’s easy to try it yourself and collect before/after results. Here’s what I observed before vagrant-cachier:
$ time vagrant up Bringing machine 'default' up with 'virtualbox' provider... [default] Importing base box 'ubuntu-14.04-x86'... [default] Matching MAC address for NAT networking... [default] Setting the name of the VM... ... real4m44.142s user0m4.895s sys0m3.132s $
After enabling vagrant-cachier:
$ time vagrant up Bringing machine 'default' up with 'virtualbox' provider... [default] Importing base box 'ubuntu-14.04-x86'... [default] Matching MAC address for NAT networking... [default] Setting the name of the VM... ... real3m18.506s user0m7.617s sys0m5.261s $
In this real-world example of a simple VM running MySQL downloading dependencies over a VPN, I was able to reduce the provisioning time by 30%! The effect in real time is larger of course for VMs that have more dependencies.
Many thanks to @fgrehm for vagrant-cachier, which helps to eliminate much of the pain of waiting for VMs to come up when using Vagrant and Chef.
Find out more at http://fgrehm.viewdocs.io/vagrant-cachier.
- Your Team Might Not Be As Effective As You Think
- Faster Feedback Loop on Code Reviews
- Surfacing Abstractions in Code Reviews
- Architecting for the Value Stream
- Article Index
subscribe via RSS