My Development Environment

by Ryan on May 5, 2010

For the last two years I have been developing applications by using a virtualized development server as main my development environment. This process has worked out extremely well since a virtualized environment is always accessible, easy to replicate, easy to access, and is able to mimic production down to every last detail.

Always accessible

Since the development server is running on my computer, it’s always available. It does not matter if I am disconnected from the Internet, or the internal network at work, I am always able to access my development server. This is especially nice when taking long flights, because I able to write and test code with no external network dependencies.

Easy to Replicate

Virtual Machines are just files on the hard drive, which means they can easily be copied and shared. The size of the files are roughly the same size as the hard drive size that was chosen during the setup. Giving the development server a smaller hard drive is going to make sharing the environment much easier.

I use an 8gb hard drive for my machines. I find this generally gives me enough space and is easy enough to share. Sharing a development environment comes in handy when the development server takes a while to configure. If the development OS requires a lot of third party software or tweaking before it is able to run any code then saving and reusing the virtual machine will save a ton of time.

I recommend setting up a virtual environment, installing the OS and all of the required services/tweaks. Before you write any code backup the the virtual machine files. This will give you a good base system (restore point) if you ever need to setup the same environment on another computer.

The development environment will running on each developers computer, so developer A can break his environment without affecting any of developer B’s work. This is really nice when it comes to experimenting with operating system and software upgrades.

Easy to Access

Virtualized environments allow you to easily share files between your computer and the virtual machine. This means you can edit your code through your favorite desktop IDE and save it right to your development environment without having to move or transfer the files. This makes accessing your project or code repositories really easy from any virtual machine installed on your computer.

You can also share folders by using Samba, SSHFS, or FTP. However, those services are generally a lot slower and require some sort of configuration.

Mimic Production

Being able to have your development mimic your production environment is a must. It eliminates bugs, makes testing more effective, and makes coding a lot easier. Virtual machines are a great way to have your development environment be an exact replica of your production server. You can setup your development machine to have the same OS/PHP/MySQL/Apache/etc versions as production.

I have a Macbook Pro laptop, a Windows desktop, and an Ubuntu desktop that I write code from. Without virtualization I would never be able to code from all three of these machines. Some of the projects that I have worked on have deep dependencies (down to the OS version). Even with a pretty universal language like PHP you would be surprised to learn the number of functions/extensions that only work on certain operating systems. Using a virtual development environment instantly solves these problems.

One project per Machine

Aside from hard drive space, there is no limit to the number of virtual machines you can have. Most applications, especially web apps, start out as simple projects with little or no dependencies. However, over time these projects grow and start to rely on a specific database or language version. This creates the need to have each project have its own virtual machine.

I try to develop every project on a virtual machine that closely mimics that project’s production environment. This means a lot of different development environments, which really is not a problem. It’s a good rule to follow and it’s a necessary rule when dealing with complex projects.

Getting Started

I would recommend Oracle’s VirtualBox for running your development environment. It’s free and takes minutes to install, setup, and configure. I also wrote a guide for installing CentOs with VirtualBox.

11 Responses leave one →
  1. Kjartan permalink
    May 21, 2010

    I’ve never tried that, because I have always thought that virtualization is too slow… Am I wrong?

  2. May 22, 2010

    Kjartan, you would be surprised how fast it is. I was pretty amazed to see how quickly the VMs ran, especially with the shared folders. If your computer has 2gb of ram (give 512 to the vm) you wont really notice any speed issues for your standard php/python/ruby based web app.

  3. May 22, 2010

    I’ve used Visual Studio in virtualized Windows extensively, it worked great, almost as fast as on the host OS. The downside is that it uses a lot of RAM.

  4. May 22, 2010

    Sorry, you use it for deployment of an application or for writing code? Because if you manage to run an IDE in a virtual machine you must have a NASA computer… (I know you have not to use IDEs, but with certain languages they are mandatory.)

  5. May 22, 2010

    Giorgio/Aleksandar,

    Running an IDE inside the VM would be insane, and would require a pretty nice computer.

    The point of my post was to run the IDE on the host computer, which can access all of the files on the virtual machine. To do this you do not need a NASA computer or anything of the like. I’m currently doing this on a laptop with 2gb of ram and it works flawlessly.

  6. May 22, 2010

    I have a modest (2.5 year old) dual core laptop with 3Gb of RAM running Windows 7.

    I do all of my development work in a VM image of Ubuntu 10.04 and it is immensely usable; I’ve never had any issues with performance, especially since the latest release of Ubuntu. I HIGHLY recommend it as a way of working, certainly gives me the best of both of the Windows and Linux worlds, plus the advantages that come with being able to revert your VM to a good snapshot in time if things go really wrong!

    I agree with the recommendation of VirtualBox too, free and easy enough to configure.

    If you aren’t sure about it then please take the hour or 2 it will take to download VirtualBox and install Ubuntu into it; I have found it to be more than worth the modest time requirement.

  7. YaoCL permalink
    May 22, 2010

    Run VM as a virtual server for web app is good.
    But I am doing JavaEE development.

  8. Frederic permalink
    May 23, 2010

    Guys. You are wrong about the IDE inside a vm.
    I ran 2 instances of VS2008 inside a VM on my laptop all time.
    It is almost as fast as native. My laptop is a basic laptop except I put 4 gig of ram because of the VMs.
    I use VMWare by the way.

  9. Paco permalink
    May 25, 2010

    I tried several virtual machines (Vmware, virtual box, xen) The main difference between virtual and native is the harddisc IO. I run 2 solid state drives in raid to get less annoying performance in IDEs like Visual Studio. My experience is that it is never fast enough. Virtualization is slower than native, at least a little bit, and about 10-30% for disc IO. When I would never had to use windows, I would be fine with a linux install script that installs and configures all the software I use. It isn’t worth the effort to create such a script for windows (when it is even possible). Virtual machines work for about everything, but for development, boxes can never be fast enough. (unless you work on very small programs with lightweight tools)

  10. Gustavo Freitas permalink
    May 26, 2010

    Interesting! I liked the idea of running a production server in a VM. It’s really good for tests and deploying applications to the guest OS. Doing that you’re able to share the repository with your team.

    Really good!

    Thanks guy

  11. May 27, 2010

    Yes, it’s an important point to remember- Windows doesn’t behave anywhere near as well as linux when it comes to running inside a VM. As I said, I find a Windows7 host for my (rare) need to work in .net is fine. All the real work gets done in Ubuntu.
    I disagree with Paco on one point- a VM is plenty fast for most development outside the Microsoft ecosystem; I see next to no overhead when writing to an ext2 partition inside my VM, but again I wouldn’t want to ask windows to do the same thing without expecting a significant performance hit.
    If you’re happy to try linux (especially Ubuntu) then you can’t go far wrong with a VM.

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS