Speed up a vagrant machine on windows

Vagrant is a great tool for developing a SilverStripe site, it's easy to set up a new VM for each project. Unfortunately it's really really slow on windows, even on an up-to-date workstation laptop with good CPU, much RAM and SSD.

The bottleneck is VirtualBox's shared folder, it's a never ending coffee break. And SilverStripe has a lot of small files, so it's really a lot to to sync.

But windows doesn't have NFS, does it? Well, there are NFS servers for Win, and even a vagrant nfs plugin, that delivers it out of the box.

So let's install that plugin:

$ vagrant plugin install vagrant-winnfsd

On an issue I was told to enable Windows 8 compatibility mode when I'm running this on Windows 10. I dunno if this is really necessary, but it won't hurt.

After some struggeling I found a config that works, now my VagrantFile looks like this:

Vagrant.configure(2) do |config|
  config.vm.box = "zauberfisch/silverstripe-wheezy64"

  #nfs setup
  config.vm.network "private_network", type: "dhcp"
  config.vm.synced_folder ".", "/vagrant",
                          :nfs => true,
                          :mount_options => [
                           'nfsvers=3',
                           'vers=3',
                           'actimeo=1',
                           'rsize=8192',
                           'wsize=8192',
                           'timeo=14',
                           :nolock,
                           :udp,
                           :intr,
                           # :user, #activating this mounts noexec!
                           :auto,
                           :exec,
                           :rw
                          ],
                          group: nil,
                          owner: nil #
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "1024"

    vb.cpus = 2
  end
end

How much speed does that setting bring? It feels fast, but can you measure it?

Last week i measured a plain SilverStripe installation for my xdebug talk at StripeCon 2016. A normal, cached page needed - take a seat - 3234ms. That's half of a lunch break.

With nfs we only need 357ms when all caches are warm. That's a lot faster and I really look forward enjoying the new speed while developing with my zauberfisch vagrant VM.

Update:

I had troubles with the original settings, because it was always mounting as noexec, no matter i defined :exec in the config. For a normal webserver that's no problem, but if you want to run unit tests inside your VM with a composer installed phpunit, it doesn't work, cause you are not allowed to execute /vendor/bin/phpunit.

I searched for a solution and... found it. It's basically the user setting overwriting exec with noexec if it's called afterwards. I guess vagrant is ordering the settings alphabetically, dunno, but commenting out :user fixed it for me.

Rate this post (1 rating(s))

Post your comment

Comments

  • Steve Olotu 15/12/2018 12:56pm (5 years ago)

    Thanks, really helpful, helped me from ~26 seconds to ~0.5!

  • Robert Attfield 08/06/2017 11:46am (7 years ago)

    If you're wanting to run a Silverstripe dev machine (Ubuntu Xenial x64) on a Windows 10 host (or even a *nix host), have a look at my setup @ https://github.com/rattfieldnz/silverstripe-vagrant-dev-machine. I've recently started to learn Silverstripe (I have experience in Wordpress, Laravel, Drupal), and made a way of deploying a dev machine based on my contractor bosses recommendations. Of course, it's definitely not for deploying a production-ready machine, although feel free to contribute (or give me pointers) if you like.

  • Werner Krauss 08/11/2016 3:25pm (7 years ago)

    Running unit tests is like 32.72s (NFS) vs 57.64s (synced folders) with warm cache/manifest, so pretty double as fast using NFS.

  • Werner Krauss 08/11/2016 12:29pm (7 years ago)

    One pitfall to be aware is still that windows file system is case insensitive. So file_exists('Foo') will return false even if a file or directory called "foo" exists, but crash later on, e.g. when running the actual mkdir() command.

  • Pali 19/10/2016 8:40am (7 years ago)

    Excellent Werner, we will test your setup on our vagrants. I will let you know.

RSS feed for comments on this page | RSS feed for all comments