Laravel Homestead TTFB very high

I use Laravel Homestead to develop on two machines. I use it because with this solution I have the same development environment in all my machines and in all machines of my coworkers.

Last Tuesday, with the monthly Microsoft update (I suppose), the HTTP responses starts to become very slow, with TTFB (time to the first byte) from 4 to 10 seconds.

To solve this problem, I have tested a lot of configurations, forums, posts,…

In the next paragraphs, I resume how I can solve this problem.

In my work machine (Windows 10 Professional) I have uninstalled VirtualBox, Vagrant and I have removed the Homestead folder (placed in the user home directory, with a previous backup of the Homestead.yaml file) and the virtual machine files (available at C:\Users\my_user\VirtualBox VMs).

I have reboot the host machine.

I have installed the latest versions of VirtualBox (5.1.18) and Vagrant (1.9.2), with the graphical installers.

I have downloaded and I have added the Homestead box, with the command:

vagrant box add laravel/homestead

I have cloned the latest Homestead repository, with the command:

cd ~ (or cd)
git clone https://github.com/laravel/homestead.git Homestead 
cd Homestead 
init.bat

I have replaced the Homestead.yaml in the Homestead folder (not in the old .homestead folder) with the backup.

When I have executed “vagrant up”, Vagrant have mounted the shared folders, but the TTFB go on very high.

Then I have added the “vagrant-winnfsd” to manage and adds support for NFS on Windows:

vagrant plugin install vagrant-winnfsd

I have added the “nfs” reference in the Homestead.yaml file

folders:
 - map: C:\Users\my_user\development
 to: /home/vagrant/Code
 type: "nfs"

I have restarted the Vagrant machine and I have loaded the new Vagrantfile configuration with the command:

vagrant reload --provision

Once I start to work with this new machine, the TTFB have decreased a lot.

Be careful with the firewall, if you have one, because it can cut the communication between the NFS and the VM.

3 comments

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.