0
votes

I've recently checked out a project that hasn't been touched in 8 months.

On vagrant up-ing I'm finding that any connections made to the guest are ridiculously slow, for example 12 database CRUD operations are taking five minutes to execute against the database on the guest (and it's not the database operations taking the time).

I'm finding though if I ping stackoverflow from both the Windows host and the guest they're returning very similar times back.

Annoyingly there's been quite a few changes since I was last able to get this working due to the previous vagrant box not working. Changes are as follows:

  • Changing of the actual vagrant box from centos[6.5] to Centos/6
  • introduction of --natdnshostresolver1 and --natdnsproxy1 (to try fix this problem)
  • Addition of config.vm.synced_folder ".", "/vagrant", type: "virtualbox" (required or the vagrant up failed)

My vagrantfile is as follows:

Vagrant.configure("2") do |config|

config.vm.box = "centos/6"

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

config.vm.hostname = "DEV"

config.vm.provision "shell" do |s|
    s.path = "build.sh"
    s.args = ["development"]
end

config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
config.vm.synced_folder "../releases", "/mnt/releases"
config.vm.synced_folder "../sites", "/mnt/releases/sites"
config.vm.synced_folder "../environment/components", "/mnt/components"
config.vm.synced_folder "../environment/scripts", "/mnt/scripts"
config.vm.synced_folder "../core", "/mnt/releases/core"
config.vm.synced_folder "../controller", "/mnt/releases/controller"

config.vm.network :forwarded_port, guest: 80, host: 8000
config.vm.network :forwarded_port, guest: 3306, host: 3306
config.vm.network :forwarded_port, guest: 8080, host: 8080
config.vm.network :forwarded_port, guest: 22000, host: 22000

end

Vagrant version is 1.9.2 (downgraded from 1.9.3 and 1.9.4) Virtual box version is 5.1.18

1

1 Answers

0
votes

So after lots and lots of searching it appears the problem is with VirtualBox rather than Vagrant.

I came across many posts which say adjust the nictype in the vagrant file like such. This is to adjust the virtual networking hardware provided by virtualbox.

config.vm.provider "virtualbox" do |v|
    v.customize ["modifyvm", :id, "--nictype1", "82540EM"]
end

Other suggestions were virtio and AMD, this feature and settings can be read in the official documentation here: https://www.virtualbox.org/manual/ch06.html.

However

This barely did anything for me if I'm honest.

After more digging I came across this article How to speed up virtual machines in VirtualBox enormously with a simple tweak which simply put 'switch power plans to boost performance'. I was skeptical, but I run a laptop on powersaver so i'd thought I might as well give it a go. It genuinely solved the problem.