bogeymin
bogeymin

Reputation: 685

Why is Django so slow on VirtualBox VM created with Vagrant?

Running a headless instance created with Vagrant. From the web browser, Django seems to be fine, but runserver reloads are delayed by several seconds after changing a file, and in fact all of the management commands are noticeably sluggish.

Upvotes: 1

Views: 1326

Answers (4)

user1012513
user1012513

Reputation: 2355

I had this issue too. Thanks @Shoan, it helped me to solve the problem. But Shoan's settings shows following error in vagrant.

NFS requires a host-only network to be created. Please add a host-only network to the machine (with either DHCP or a static IP) for NFS to work.

But I found a solution too for above issue. See my setup as follows.

Vagrant.configure(2) do |config|

config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder ".", "/vagrant", nfs: true

end

Hope it will help.

Upvotes: 1

Shoan
Shoan

Reputation: 4078

Vagrant 2.0 allows you to setup NFS mounts. From the docs:

Vagrant.configure("2") do |config|
  # ...

  config.vm.synced_folder ".", "/vagrant", nfs: true
end

Upvotes: 2

Terry Wang
Terry Wang

Reputation: 13920

VirtualBox's vboxsf used by default by Vagrant synced files has performance issues when there are large number of files/directories. Consider using sshfs or NFS.

Upvotes: 3

bogeymin
bogeymin

Reputation: 685

Apparently, this can be caused by a large number of files in the project directory -- some sort of issue with sharing between host and guest. In this case, I was running the Python virtual environment in the same directory as the project, and it includes about 10K files. Moving the virtual environment to another location on the VM has greatly improved performance.

Upvotes: 2

Related Questions