Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default mount type and slow VM #1428

Open
5 tasks done
LucasDemea opened this issue Sep 27, 2022 · 6 comments
Open
5 tasks done

Default mount type and slow VM #1428

LucasDemea opened this issue Sep 27, 2022 · 6 comments
Labels

Comments

@LucasDemea
Copy link
Contributor

Terms

Description

What's wrong?

On a linux host (ubuntu 22.04), my VMs have really bad performance. The TTFB is around 5-6 sec, and navigating the back-end is a pain, often having to wait 10-15 secs for a page to load.
I also noticed some very long durations, sometimes leading to timeouts when doing operation such as rm -rf vendor, or
composer install inside the VM. The same operations are at least 10x faster when I run them on the host.

What have you tried?

I found that the R/W speeds are bad inside the NFS mounted folders, so I tried the other protocols, by changing the vagrant_mount_type: setting in vagrant.default.yml to virtualbox.
I compared the writing speeds with dd if=/dev/zero of=./test bs=1M count=1000 inside one of the shared folders, and found that virtualbox protocol had much better results than NFS:

  • 125 MB/s with NFS protocol
  • 1.2 GB/s with virtualbox protocol

The TTFB is also reduced, and navigating my sites is much faster.

What insights have you gained?

In my case, and possibly on other Linux hosts, the virtualbox shared folders protocol is much faster than NFS.

Suggestions

We first need more testing from the community, but virtualbox protocol could be suggested as the default trellis protocol.

Steps To Reproduce

Switch the vagrant_mount_type setting from nfs to virtualbox and run vagrant reload.

Expected Behavior

NFS should be the fastest protocol

Actual Behavior

virtualbox is faster than NFS

Relevant Log Output

No response

Versions

ubuntu 22.04, trellis 1.9.1, vagrant 2.3.0, virtualbox 6.1.38

@LucasDemea LucasDemea added the bug label Sep 27, 2022
@swalkinshaw
Copy link
Member

swalkinshaw commented Sep 28, 2022

Interesting!

Here's an older article by the Vagrant creator: https://mitchellh.com/writing/comparing-filesystem-performance-in-virtual-machines

I found https://github.com/winnfsd/vagrant-winnfsd/wiki/Benchmarking-winnfsd-vs-VirtualBox-Shared-Folders and winnfsd/vagrant-winnfsd#46 which has some benchmarks and some good discussion on how to benchmark different types of FS operations.

Both seem to recommend NFS overall, but more specifically when reads are more important which is true for running a WordPress site for example (in normal situations). But for operations like running composer install, that's a lot of writes where vboxfs should win out.

Maybe this is different on a Linux host though?

It would be interesting to trace how many reads + writes are involved in a page load.

@LucasDemea
Copy link
Contributor Author

Thank you for the resources. I will do more in-depth testing when I get the time.

@LucasDemea
Copy link
Contributor Author

LucasDemea commented Nov 1, 2022

I did more testing, using the fio tool this time.

I followed the recommended methodology detailed in this post as a base.

I'm not at all an expert in filesystems, and I won't pretend these tests have any scientific value. But I still think the results are interesting and could open the discussion, and maybe someone more knowledgeable could participate.

Host setup:

Samsung SSD 970 EVO Plus 1TB
ubuntu 22.10, vagrant 2.3.2, virtualbox 7.0.2, trellis 1.9.1

Guest setup:

vagrant_cpus: 4
vagrant_memory: 2048

The results

Random write speed (MiB/s)

NFS Virtualbox
Single 4KiB 27.2 52.1
16 parallel 64KiB 165 1309
Single 1MiB 109 993

Random read speed (MiB/s)

NFS Virtualbox
Single 4KiB 9 66.7
16 parallel 64KiB 64.7 1653
Single 1MiB 246 1365

We can see that virtualbox mount type outperforms (by far) NFS, for both reading & writing.

@swalkinshaw
Copy link
Member

Wow that's huge. I can't test this on macOS unfortunately since I'm using Parallels for ARM.

@swalkinshaw
Copy link
Member

@LucasDemea I'm hesitant to make this change the default for all Linux users without some more data points from other users. But in the meantime, would you be interested in adding a section to our Vagrant docs about mount types specifically about Linux + VB?

@LucasDemea
Copy link
Contributor Author

I agree that we need some feedback from other users before making the change.
I'll create a PR to the docs when I get the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants