Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow vagrant box, how to improve this?

We've built a vagrant box for our development box and we are facing some latency issues.

Issues:

  • Assetic:watch is being slow
  • Overall application access in (app_dev.php) is slow
  • Using "find" command in the shared folder on the vagrant box is super slow

About the box:

  • Running on virtualbox (running on both Mac and Linux)
  • LAMP env (ubuntu)
  • Big code base (10K+ files)
  • Symfony 2 application

Things done to improve perfs:

  • Use of NTFS (using bindfs)
  • Vagrant configs:

config.vm.synced_folder "#{folder['source']}", "/mnt/vagrant-#{i}", id: "#{i}", type: 'nfs', mount_options: ['rw', 'vers=3', 'tcp', 'fsc' ,'actimeo=2']

  • Move cache and logs out of the shared folder (AppKernel update)

We can clearly see that any time a file from the shared folder is accessed the "bindfs" process is eating a lot of cpu.

First of all is that normal? I was expecting vagrant to copy files on the box an whenever those files were being accessed things were done locally.

We can see that the box itself works fine as when accessing cache data (outside of shared folder) things are going fast enough so what can I do to improve the box performances and avoid those latency issue?

like image 970
LEM01 Avatar asked Jan 11 '16 19:01

LEM01


2 Answers

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

like image 118
Blackcoat77 Avatar answered Sep 29 '22 14:09

Blackcoat77


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 :

  1. http://www.erikaheidi.com/blog/optimizing-symfony-applications-on-vagrant-boxes/
  2. http://www.whitewashing.de/2013/08/19/speedup_symfony2_on_vagrant_boxes.html
  3. Symfony2 Slow Initialization Time
like image 21
Nikola Loncar Avatar answered Sep 29 '22 13:09

Nikola Loncar