Improving composer build performance¶
Opting for composer based installs will most likely increase your VM's time to provision considerably.
If you manage multiple VM's own your computer, you can use the
vagrant-cachier plugin to share Composer's package cache across all VM's. The first build will be as slow as before but subsequent builds with the same
geerlingguy/ubuntu1604) will be much faster.
Install the plugin on your host computer:
vagrant plugin install vagrant-cachier.
Vagrantfile includes the appropriate
vagrant-cachier configuration to cache Composer and apt dependencies.
You can also use this plugin to share other package manager caches. For more information read the documentation.
Synced Folder Performance¶
Using different synced folder mechanisms can have a dramatic impact on your Drupal site's performance. Please read through the following blog posts for a thorough overview of synced folder performance:
- Comparing filesystem performance in Virtual Machines
- NFS, rsync, and shared folder performance in Vagrant VMs
- NFS offers a decent tradeoff between performance and ease of use
- SMB offers a similar tradeoff, but is a bit slower than NFS
- Rsync offers the best performance inside the VM, but sync is currently one-way-only (from host to VM), which can make certain development workflows burdensome
- Native shared folders offer abysmal performance; only use this mechanism as a last resort!
If you are using rsync, it is advised to exclude certain directories so that they aren't synced. These include version control directories, database exports and Drupal's files directory.
vagrant_synced_folders: - local_path: . destination: /var/www/drupalvm type: rsync create: true excluded_paths: - drupal/private - drupal/public/.git - drupal/public/sites/default/files - drupal/tmp
This example assumes that you have Drupal in a directory called
Improving performance on Windows¶
By default, if you use the NFS synced folder type, Vagrant will ignore this directive and use the native (usually slow) VirtualBox shared folder system instead. You can get higher performance by doing one of the following (all of these steps require a full VM reload (
vagrant reload) to take effect):
- Install the
vagrant-winnfsdplugin. See the 'NFS' section later for more details and caveats.
smbfor the synced folder's type.
rsyncfor the synced folder's type. This requires that you have
rsyncavailable on your Windows workstation, which you can get if you install a substitute CLI like Cygwin or Cmder.
You can use the vagrant-winnfsd plugin to get NFS support on windows. Be aware that there are multiple issues logged against both the plugin and the winnfsd project, so no guarantees.
Using WinNFSD without
Another option for the more adventurous is to manually install and configure WinNFSD, and manually mount the shares within your VM. This requires a bit more work, but could be more stable on Windows; see this blog post for more details: Windows + Vagrant + WinNFSD without file update problems.
GuyPaddock's fork of
vagrant-winnfsd adds logging and debug messages. You can replace the vagrant-winnfsd gem inside
.vagrant.d\gems\gems to use it instead. For further caveats, please read through vagrant-winnfsd issue #12, and make the following changes to
mount_options to your synced folder to avoid an error:
type: nfs mount_options: ["rw","vers=3","udp","nolock"]
In a custom
Vagrantfile.local, add user access to Vagrant: