Recently I started using Vagrant as part of my development environment. Could not be happier, however, one small issue has become very very irretatating.

Letency!

That initial 'hang' is slowing me down

So lets have a look at what is going on:

Using Chrome dev tools, I can see there is a 7.65s page load latency.

Latency 

No wonder I am getting frustrated.
This is over a private network. It should be instant!.
So what could be the issue?

My intial thoughts would be DNS, so I use dthe virtualbox IP directly. This made no difference.

Next I considered CPU's and memory on the guest.  
I increase CPU to 2, and memory to 9GB - No change.

Next I considered networking.
Some googling showed that using the 'virtio' adapter in virtualbox can decrease latency on internal networks.
So I changed the network adapters in the vagrant file:

vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
vb.customize ["modifyvm", :id, "--nictype2", "virtio"]

and issued a 'vagrant reload'

A new test showed a decrease in latency of .10ms - not good enough, but a little bit better.
Seems like using virtio may be faster.

Next, I considered the issue must be with apache.
I needed to determine if the vagrant box is receiving the initial connecion instantaniously, and that it may be apache farting about, waiting to send back the initial data.

I used 'tcpdump' for this.

ssh'ing into the vagrant box, i issued the following command:

sudo tcpdump -i eth1
 

I then refreshed the page. 

tcpdump showed that the request hits port 80 INSTANTLY. So, the issue is apache itself.