We\'ve built a vagrant box for our development box and we are facing some latency issues.
Issues:
consider allowing the VM to use one or two additional CPU core. This can be controlled from virtualbox gui interface or with a vagrant config. See bottom of this page https://www.vagrantup.com/docs/virtualbox/configuration.html
make sure your VM is running on a SSD drive (if budget is ok with that)
You need also to don't share vendor folder between host and vagrant, if you are doing that. Because reading of shared files are slow. Take look at this link. In order to do that you will need to change composer.json file inside you symfony2 project :
"config": {
...,
"vendor-dir": "/some_new_location/vendor"
},
and also change app/autoload.php
.
$loader = require '/some_new_location/vendor/autoload.php';
After doing that run composer install.
There are also some resources for reading :
If you work with Phpstorm you can use deployement module to syncing files from base machine to virtual
Then every change on local machine will upload file to virtual machine. This will shoot up your performance. I tried a lot of solutions, but every was not enough for me such as. move cache folder away, unshare vendor folder...
For any googlers out there:
In the file .env
CACHE_DRIVER=memcached
(Instead of CACHE_DRIVER=array)
Very slow laravel homestead/vagrant/virtualbox on Mac OSX
Late to the game. For newcomers there are 2 plugins which will increase the speed of the vagrant box right of the bat.
vagrant-cachier
Installation
Make sure you have Vagrant 1.4+ and run: vagrant plugin install vagrant-cachier
Vagrant-faster
vagrant plugin install vagrant-faster
I'm also using MySQL-tuner-perl which is quite good for MySQL fine tuning.
I hope it helps
For the test you can try to boot a vagrant without auto sync option for a shared folder, e.g. :
config.vm.synced_folder "./", "/home/vagrant/APP/", disabled: true
now you will experience the vagrant (web app) maximum speed, everything should be at least twice faster. But now nothing is synced between a host and the virtual machine.
Now you just add specific folders "without disabled: true" where development is taking place "src", "public", "tests" etc. and now speed should be very similar as first test, e.g. :
config.vm.synced_folder "./src", "/home/vagrant/APP/src", disabled: true
config.vm.synced_folder "./public", "/home/vagrant/APP/public", disabled: true
Folders with many files like ".git", "vendor", "node_modules", etc. really slow down a vagrant performance.
My phpunit tests lasted 12 minutes before that optimization and 4.5 min after this optimization (win host)
Enjoy.
For reference here is my config for homestead (laravel) :
folders:
- map: "./"
to: "/home/vagrant/APP"
type: "nfs"
options:
disabled: true
- map: "./app"
to: "/home/vagrant/APP/app"
type: "nfs"
- map: "./resources"
to: "/home/vagrant/APP/resources"
type: "nfs"
- map: "./routes"
to: "/home/vagrant/APP/routes"
type: "nfs"
- map: "./tests"
to: "/home/vagrant/APP/tests"
type: "nfs"
- map: "./public"
to: "/home/vagrant/APP/public"
type: "nfs"