WinNFSd - How to Speed Up You Vagrant Environment on Windows

in Backend, Culture by Damian on November 3rd, 2015

In DeSmart we use Vagrant on a daily basis. Whatever the reason to work on the system without native support for NFS (Network File System), yes, I'm talking about Windows, you can feel that every request to localhost can be a pain in the ass.

3.2s to load the home page with one db query? Seriously?!

Ok, so really what can we do about that? We are working on Windows and there is no native support for anything else than Synced folders.

Same situation happens when you’re trying to work on the files directly on a virtual machine doing stuff like:

 

git status //etc
composer install 

 

We face another problem when we use synced folders on the apache server, running from virtual machine, using synced files in vhost file. This is the reason why that request takes a long time to serve even cached files.

I just switched from Vim to another IDE, so I don’t have the need or possibility to work inside a machine any more. When I worked with Vim, I never synced my project files with host machine. That way it worked pretty smoothly, because I didn’t need to use sync folders. My whole dev env was inside the virtual machine and there was just one bash script to set that up, we all love Vim ;)

Back to the topic, I found promising repository, at least the most updated one, with some WinNFSd source code. Based on that, and including some minor pull requests, I was able to create a binary that works quite nicely.

Here is what you CANNOT do:

  • composer install in some cases, if your package needs to compile some binaries, basically that makes it impossible to execute a command

Here is what you CAN do:

  • work with shared folders blazing fast

A known issue:

  • you need to execute nfsservice halt before each vagrant reload

Here is a code WinNFSd binary and WIKI

Feel free to dig into it, and follow instructions from WIKI page.

All of that will force you to have php and composer on your host machine, in this case Windows.

I didn’t find a way to make it possible to execute composer install when NFS is switched on in my puphet file.

Here is my flow when I need to execute composer install

  • change sync_type:'nfs' to sync_type:'default'
  • reload vagrant
  • execute composer install command
  • change back to NFS
  • reload vagrant

This is not as bad as it sounds, it’s much better to reload your vagrant than wait 3s on every request to your localhost.

Plus have a look at this:

This is the same homepage in about 0.5s. Nice one!

You need to get used to executing vagrante reload when needed, but you can improve your daily workflow with that.


← back to the blog

You May Also Like

What Is a Code Audit and Why Do You Need It

by Piotr in on January 22nd, 2017

The source code of your application might be right or wrong. You won’t find out until you run a code audit with external developers. If you want to make sure your digital product was created with high-quality code, check our offer!

Dump Links #3 - Make a Clean Code

by Kamil in , on October 21st, 2015

Another portion of cool tools found on the Internet and useful in developer's everyday life.

London Calling - Why there Are More Selfie Sticks than Umbrellas?

by Damian in on October 13th, 2015

I was in London before but London has changed and I changed also. This is my thoughts from business trip to London.

Interested in Creating a Successful Project?

Contact us and together we'll bring your ideas to life!