How to speed up Drupal running in Vagrant on Windows Host

I recently install and setup Vagrant on my Windows laptop. The only reason I used Windows on my laptop is because of the trainings I conduct. Most companies use Windows based systems and it is difficult to train them if you are showing demos on Linux and they have to repeat the same on Windows. For that reason only I used Windows. When I am not providing training, I am usually developing stuff. Mostly on Drupal and most recently on JIRA Plugins (Yes I am learning Java).

I heard about Vagrant in the past but never really had enough space to try it out. Recently I decided to not take usuall Drupal projects and will only work with smart clients who are willing to pay for the service and quality. That decision is costing me money, as I don't do lot of work now but I am happy with the peace on mind. This gives me with some extra time which I now devote in learning new things and improving processes in my company. When you are on your own, you need to spend your time wisely. Free time means opportunity to learn new stuff.

I was happy to understand the whole workflow of Vagrant and quite like it actually. Everything went fine. Installed CentOS 6.5 using Vagrant and setup LAMP on it. I even installed a blank Drupal site just to test it out. It worked fine too. I even created a package and moved this customized CentOS box to another machine and it worked perfectly too. I loved this idea to have exact same development environment. I will now ask everyone in the team to use this box.

So far it was great, until I actually cloned one of our complex Drupal project which we have to deliver in few days. That site was running horribly slow. I came to know that the performance can be increased if we enable NFS for file sharing but unfortunately NFS is not supported on windows.

So I searched a lot on google for possible improvements. I mean Vagrant can be installed on Windows but just because of this NFS issue it is impossible to use it for LAMP. Finally I found we tricks, which I applied and it really improved the performance. Not great but atleast usable.

Install the following Vagrant plugin in your host, Windows in my case.
Someone has written this plugin to enable NFS on Windows. I found this after searching a lot on google.

  1. vagrant plugin install vagrant-winnfsd

Now enable the root of your project folder with /vagrant folder where I keep my website files. This could be any directory on your setup. don't forget to enable NFS by using type: "nfs"

Do the following change in your Vagrantfile.

  1. config.vm.synced_folder ".", "/vagrant", type: "nfs"

I realised that increasing the memory also has positive effects on the performance.

Also increase the memory of your virtual machine. I have 8 GB of RAM so I can afford to allocate 3GB to my virtual machine.

  1. config.vm.provider "virtualbox" do |vb|
  2.     vb.customize ["modifyvm", :id, "--memory", "3000"]
  3. end

Lastly some tweaks in the Apache configuration file for some extra improvements.

Finally do the following change in your httpd.conf file

  1. <IfModule prefork.c>
  2. StartServers       2
  3. MinSpareServers    6
  4. MaxSpareServers   4
  5. ServerLimit      4
  6. MaxClients       4
  7. MaxRequestsPerChild  3000
  8. </IfModule>

These are some of the things that I tried, I cannot guarantee that it will help you too, but there is not harm in trying. It might work for you.

Have fun!

Add new comment

Want to contact me?

Life begins outside your comfort zone and that is where your courage is developed". Write to me by filling this form. For living I am an Atlassian Consultant who love both Jira and Drupal. I am the author of "Mastering JIRA" and "Mastering JIRA 7" books. I Love both JIRA and Drupal (a bit more). You can Write To Me and I will get back to you as soon as I can. Have a nice day!

Social Links

Subscribe to my mailing list.

Enter your email address: