Slow vagrant box, how to improve this?

前端 未结 7 931
没有蜡笔的小新
没有蜡笔的小新 2021-02-06 05:21

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

Issues:

  • Assetic:watch is being slow
  • Ove
7条回答
  •  北恋
    北恋 (楼主)
    2021-02-06 06:10

    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"
    

提交回复
热议问题