9

I see a few developers that like to use virtual machines for web development. Are there others that do this? If there are, why do you do it? Are there any pros / cons to developing on a VM rather than in a non virtualised environment?

I would think things are slower in a VM.

7wp
  • 356

10 Answers10

19

I use VMs for IE testing. I do have a dedicated Windows machine, but I lean towards using VMs for a few reasons:

  • It's a hassle to switch computers, even if it's right next to you
  • It's extremely easy to rollback a VM to have a clean testing environment
  • I'd rather use an environment users are actually going to use rather than kludges like IETester, and you generally can't run multiple versions of IE at the same time.
  • It's cheaper to run multiple VM instances than it is to buy multiple testing computers
  • VMs, at least the ones for Mac OS X, have gotten so good in the past couple of years that the "slow" stigma given to VMs is unwarranted.
6

The other reason people use a VM for web development is to virtualise a server environment that they can turn off really easily.

At home I always use a VM for setting up personal projects so that I can turn it all off completely when I want to, say, play a game. In a work environment you might want to turn it off so that you have full resources to transcode a video to FLV.

It just gives you that flexibility to do what you want with your resources.

3

I prefer to use VMs for pretty much all development... especially when I'm working with a team of developers. VMs allow me to build an "environment in a box" that can be quickly set-up with little headache. Since I use a MBP as my primary machine, I prefer VMWare... it's a lot less painful especially in a "mostly-Windows" environment.

As far as speed is concerned, it honestly varies from setup to setup. The only real issues I've seen with VM speed involve a.) not having enough physical resources (memory, etc.) or b.) not allocating enough resources to your VM. Otherwise, I actually prefer working in a Windows VM on my Mac than working on a native box.

Casey
  • 527
2

Testing environments is a big one as others have mentioned.

  • browser testing (ie, safari, etc,...)
  • clean testing environment
  • easy to have multiple configurations
  • accessibility testing (screen readers and the like)

I have a VM strictly for profiling and debugging my code which has kcachegrind already setup, along with selenium, xdebug and a few other tools configured to easily profile and debug my code. Yes some may say this is what a development environment already would be but personally I like having a VM on my desktop dedicated to this sort of task.

Also, regarding the slowness in a VM:

Things are slower in a VM because of the overhead requires to "virtualize" the environment. However, the VM is becoming closer and closer to the hypervisor which lessens the overhead required for the VM.

Chris
  • 5,643
  • 3
  • 29
  • 39
2

I use virtual machines all the time. For testing purposes, the reasoning is obvious, but I also use it for my actual development environment, mainly because 1) it makes migration to new hardware a no-brainer, and 2) it gives me an easy "snapshot" (or set of snapshots) fall back to as needed for those configurations of my development environment. My needs may be unique -- I am primarily a Delphi developer using multiple versions of Delphi, and lots of third-party components -- but the amount of time and headache having my development environment inside of a virtual machine has saved, probably could not be overstated.

That said, don't scrimp on the box you run them on, especially when it comes to memory. ; )

Jamo
  • 131
1

This is a late answer. I agree with all the points in the accepted answer, but I wanted to add that I use VMs exclusively for Web development, and not just for testing. I'm on an iMac using VirtualBox to run Windows, Fedora, and Ubuntu -- sometimes all at once. I don't have any problems with performance.

I prefer working this way because I work for customers running both Fedora and Ubuntu servers and it allows me to closely match the development environment with the production environment. It also makes me a better systems administrator in the areas that are most important from a development standpoint.

bogeymin
  • 391
1

Have found using VMs a good way of keeping a client-specific development setup.

In a past consultancy company, Devs knew that firing up a specific VM meant you had a working environment for developing/testing and deploying the software we supported for that client. Particularly useful when supporting some real oddball systems.

For new apps, you'd have the latest and greatest setup on your main Dev machine. But what about when you need to bugfix some old VB6 app that your company still supports. Fancy installing Visual Studio 6 on your lovely clean VS2010 machine? I don't think so!

Also meant it was pretty easy for any Dev to support any client.

davewasthere
  • 131
  • 3
0

I use a virtual machine to map subdomains of virtualbox.me (I own the domain) to subdirectories of a folder on my host machine shared to the guest.

With this setup, I just create a new directory and immediately have a new project under it's own subdomain, i.e. /home/pete/virtualwww/my-super-project maps to http://my-super-project.virtualbox.me/

I've written up guide for replicating this (it uses mod_vhost_alias and VirtualDocumentRoot) here:

http://otaqui.com/blog/1652/setting-up-a-virtualbox-virtual-machine-for-web-development-with-multiple-sites-using-mod_vhost_alias-and-virtualdocumentroot/

0

I've certainly used virtual machines for testing websites, but not for writing code in.

The benefit of virtual machines is that you can have different OS's and browsers set up, to test the inevitable css bugs you'll discover in IE6 / 7 / 8.

David_001
  • 2,762
  • 2
  • 26
  • 27
0

I don't see a reason to develop websites in a virtual machine, there isn't a need for it for a Windows user.

You can run everything in a Windows install (Portable IEs, Chrome, Firefox, Safari, ...),
alternatively you could use Expression SuperPreview to enter a new world of cross-browser testing.