Vagrant slowing down http requests to rails server

1.5k views Asked by At

I have a project (Rails 4.0.2) that I'm currently running inside of Vagrant (1.3.5) running VirtualBox (4.3.4). The Guest OS is Debian 6.0. When I run the application on the Host OS, or I start up the Virtualbox manually, I see a dramatic improvement in responsiveness. As soon as I use 'vagrant up', performance seems to become really poor. Here are the relevant Apache Bench results:

Apache Bench Command

ab -n 10 -c 1 http://127.0.0.1:3000/application.js

Host OS

              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:    27   44  28.3     33     118
Waiting:       25   41  28.6     31     116
Total:         27   44  28.3     33     118

Virtualbox

              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       1
Processing:    57   71  19.1     67     119
Waiting:       46   59  19.3     57     110
Total:         57   71  19.1     68     119

Vagrant

              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   849  916  76.2    901    1115
Waiting:      831  892  72.6    883    1081
Total:        849  916  76.2    901    1115

I would expect a slowdown running the application in Virtualbox, but not an order of magnitude. I'm also not doing anything fancy with my Vagrantfile:

Vagrantfile

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   config.vm.box = "squeeze"
   config.vm.network :forwarded_port, guest: 3000, host: 3000 
end

I've tried the fixes specified in this github issue and this HackerNews comment but to no avail.

1

There are 1 answers

2
Terry Wang On BEST ANSWER

Make sure you don't place your project in synced folder (by default it uses vboxsf which has known performance issues with large numbers of files/directories).

This may also be related to "Webrick Reverse DNS Lookup", take a look at https://stackoverflow.com/a/19284483/1801697

Hope it helps.