A case for virtualization
by TheDarkTrumpet on 2008-03-29 12:08:57


Virtualization may be a term some reading this may not know about - so I should start there :) So what is virtualization? Virtualization in the sense of what I'm talking about here is the ability run an entire operating system, more or less, within an application. Why would anyone want to do this? Well, I'll get to that soon :)<br><br>
How do many people develop right now? The diagram below hopefully will illustrate it somewhat:<br><br>
<center><img src="/sitemedia/blogmedia/29March08Virtualization-1.jpg" /></center><br>
Many people take their base machine, install all these services on it, and develop right on it. Is this an OK solution? Of course - I mean if people feel comfortable with it then that's OK - but in my opinion is it the best option? Definitely not.<br><br>
why?<br><br>
Virtualization allows you to abstract the services you're using for that specific purpose. If you're developing web applications, you may want apache, postgresql, and other services installed to test your web apps. Do you only do web app development on that machine you're using? My guess is no. No one spends 100% of their time on the computer doing one single thing. For example, for myself, I spend maybe 40-50% of my off hours developing whereas the rest of my time is spent listening to music, browsing web sites, and so on. Why do I want to run postgresql all the time? Why do I want my test environment running all the time? The answer to all that is that I don't want it run all the time. I really would rather have my development environment available when I need it, but turn it off when I don't. This allows me to reduce the total number of wasted resources which would normally end up being used (unless I created scripts to kill services when not needed - I have done that in the past). Furthermore, from a security standpoint, less services accessible from the internet the better. So running all your experimental stuff in a virtual machine, without as much worry over security, is a nice peace of heart thing.<br><br>
So with that giant bit of why to do this, what do I propose one uses instead for development?<br><br>
<center><img src="/sitemedia/blogmedia/29March08Virtualization.jpg" /></center><br>
What's different about this? On my host machine, on my macbook pro in this case, I have absolutely nothing checked in my sharing tab - nothing :) This makes my machine a tad bit more secure overall than before. So what about the virtual machine you might be asking - what about its security? Well, my fine friend, basically if you set your virtual machine to use NAT, it gets an IP address from your host machine. Why use NAT? The reason I use it is because I'm only accessing the virtual machine from my macbook pro, I don't want it accessed from outside it. Furthermore it can access the net when it needs and when I'm doing development, I don't actually need the net for anything. Cool huh.<br><br>
To summarize the benefits and negatives of virtual machines:<br>
Benefits:
<ul>
<li>Abstraction of the entire development environment - much more control</li>
<li>Easier to update many packages (from a mac perspective, ports and fink aren't always reliable)</li>
<li>Considerably more secure than trying to secure all these services while running on your host machine</li>
<li>Overall CPU cycles and memory use could be improved, this assumes you keep the virtual machine off sometimes.</li>
<li>Backups are extremely simple. Want to install something risky but afraid of messing up the system? Copy the entire virtual machine file, then run the code</li>
<li>VMWare (and I'm sure others by now) have great integration with the host machine. Shared folders, to keep the code accessible on the host machine (say if you want to use textmate, but test in the VM).</li>
</ul>
Negatives:
<ul>
<li>Slightly more disk usage space. You have the overhead of the virtual machine. My test vm is roughly 2.5Gb right now and has everything I need installed - it can get larger and larger depending on what you use it with.</li>
<li>Memory use while the VM is on can be high - you will need the RAM to do this. I have 2Gb of RAM in my machine, and have roughly 500Mb either free/inactive with my virtual machine on. It has 512Mb of RAM dedicated to itself. Ram is pretty cheap, though, so having some won't hurt much I'm sure</li>
<li>sshing to test stuff may feel awkward at first. This is only if you use linux, but I do - and have shared keys all over to make sure I can log in without a password, and have scripts that run here and there that help ease the problem of virtual machine integration. Overall, this is a very weak point for me, as I rarely have problems with the integration given what I'm doing</li>
</ul>
I hope this gives a brief overview of virtual machines and what they are capable of. There are many projects out there that virtualize including VMWare (for all operating systems - my personal favorite), Parallels (for the mac), and VirtualBox (available for most operating systems - free). There are others too, you can find them through google. While I'm a huge fan of VWWare (especially their fusion product for the mac), I'd try VirtualBox with whatever you want first to see how you like it before switching over to VMWare if you so desired.
</ul>



Click here to add a comment