e thought we were going to cover a lot of topics in this episode of .NET Rocks!, but we managed to go over an hour without straying from Virtual PC at all. This is a must-listen show for anyone who isn’t already an expert in Virtual PC or Virtual Server. Brain explains the advantages and disadvantages, warns you of some potential pitfalls, and shows you how you can boost performance!
Brian A. Randell is a senior consultant with MCW Technologies, LLC, a Microsoft Certified Partner. Over the last 18 years, Brian has worked with companies and their developers to help to create solutions that leverage various Microsoft technologies. Today Brian splits up his time teaching Microsoft .NET -based technologies to developers, working with new and emerging technologies like Visual Studio 2005, SQL Server 2005 and Visual Studio Team System, and consulting worldwide for clients such as Microsoft, American Honda, DELL, and others. In addition to consulting, he speaks at events such as VSLive!, TechEd, and the PDC. He is the co-author of Effective Visual Basic and the forthcoming Tom and Huck’s Guide to Visual Basic Express (both from Addison-Wesley) and has written articles for MSDN Magazine and Microsoft. You can reach Brian through his blog site.
Carl Franklin: All right. Let’s talk about performance right now. So let’s assume that you have a Virtual PC session totally full screen. In other words, you have control. Let’s say you’ve got a gig of RAM, and you’ve assigned the maximum amount of RAM or, the maximum amount of RAM you should have, which is about 700-something Megs?
Brian Randell: Yeah, give or take.
Carl Franklin: So what kind of performance degradations are you going to find?
Brian Randell: Well, see, here is the problem: it’s multiple things. Number one, the two things that make the biggest difference are the amount of RAM you have on the host operating system, the spindle speed of your hard drive, and if you have multiple hard drives.
I’ve done [some] diagnostics. For example, just the difference between a 5400-RPM drive and a 7200-RPM drive is noticeable. So that’s the biggest thing you can do for performance is get yourself a fast, separate hard drive from your host operating system, and make sure you have gobs of RAM. And those are the two things right away, and you won’t make the big mistakes. They run stuff on 512 Megs of RAM on a 4200-RPM laptop drive.
Carl Franklin: Yeah. And a RAID Stripe will work, too?
Brian Randell: Absolutely. Anything that is going to give you better performance will work. I mean, as far as the virtual hard drive is concerned, it’s just a big file; so as long as Virtual PC or Virtual Server can see it, it will work fine.
Carl Franklin: Are there any optimizations you can do in terms of where to place that file or index it or anything?
Brian Randell: Absolutely. It’s just like a swap file. You want it on a separate spindle field hopefully, a separate physical drive than your host operating system. That’s the number-one thing. And then if the virtual PC has multiple drives, just partition them across multiple physical drives, also. The other thing is, there are different types of virtual hard drives we probably should talk about.
Carl Franklin: Okay.
Brian Randell: What most people do when they set up a virtual PC is, they take the defaults, and they like it. It’s the dynamic hard drive, which basically means, inside. The guest operating system sees it as an X gigabyte-size drive. The max you can have is a 16-gig virtual hard drive inside.
On the outside, though, it only takes as much space as you are actually using. So you start off with, say, installing Windows, and if it’s Windows XP, for example, it takes about a gig-and-a-half. So your guest operating system thinks it has 16 gigs of total disk space with, say, 14-and-a-half free; but you’re only using a gig-and-a-half on the host drive; and then as you use disk space, it slowly expands.
The problem is that slow expansion is just like correcting it on ROM, Richard, when you have dynamically expanding databases. It’s a benefit that has a performance penalty.
Richard Campbell: But it’s two things. One is, it takes time to allocate disk space; and the other thing is, it’s fragmenting.
Brian Randell: Exactly. And so if you want the best performance, use fixed hard drives and pre-allocate them. And when you do that, you can actually see significant performance improvements. Some are them are subjective; but that is measurable over a dynamic disk. The other thing is, you’ve got to keep your host drive defragmented, and you’ve got to keep your Virtual PC hard drives defragmented. Those are huge things that if you do on a regular basis, you’ll have noticeable improvement right off the bat, besides buying better hardware.
Richard Campbell: And more memory.
Brian Randell: More memory.
Carl Franklin: Inside Virtual PC, does it just look like you have more disk space available all the time?
Brian Randell: Yes, it looks … whatever you set the maximum to be, which in Virtual PC is 16 gigabytes; if you even use 2 gig, you’ve still got 14 gigs free.
Carl Franklin: Well, what if you use 40 gigs?
Brian Randell: You can’t.
Carl Franklin: All right. So you can only have a 16-gig drive.
Brian Randell: Right now in Virtual PC, that field is the maximum for what Virtual server drives are.
Carl Franklin: Oh, okay. All right. I thought when you said it “expanded”, I thought you meant it would expand past 16 gigs.
Brian Randell: No, it all expands up to the limit of the size when you create it. You specify how big you want the limit to be.
Carl Franklin: Yeah, and the limit is 16, okay.
Brian Randell: It’s currently 16, and I forget what the Virtual server number is. The Virtual server number is much bigger, because they support virtual SCSI drives. The drives in Virtual PC are IDE only.
Carl Franklin: So tell us about Virtual Server.
Brian Randell: Virtual PC is designed for interactive applications like doing help desk, beta testing, interactive use. For example, it supports Drag-and-Drop from the Desktop as a good reason to use it. And it runs as an interactive process under the logged-in user’s account. Virtual Server is designed for running old applications that don’t run on modern Windows operating systems, like Windows 2003. It’s designed for consolidation of servers where you have low utilization and you want to consolidate hardware. It’s also good for doing test scenarios. Now, Virtual Server is a server product that’s run as a Windows’ daemon (service) In addition, compared to Virtual PC, which can only utilize is only used in a single processor and it’s basically single-threaded, for all intents and purposes. Virtual Server supports multiple processors. Now, understand, when I say “multiple processors,” your guest operating system always today sees a uni-processor box. It only sees a single processor. However, Virtual Server will take advantage of multiple processors and, with the Enterprise Edition, up to 32 processors; so, very scalable. Now, both versions only allow the virtual machine guest to see up to about 3.6 gigabytes of RAM, regardless of the host availability of RAM.
Richard Campbell: “Only.”
Brian Randell: Yeah, well, “only.” Well, I try to have the max 2 gig, and my Desktop has 4 gigs and my server does, too, and I am ready for more. You know, give me more.
Geoff Maciolek: Hey, I’d actually like to cut in here. And I don’t usually ask anything during these shows, but that thing where you were just mentioning the guest operating system having a single CPU, whereas your actual hardware that you are running it on, you could do on, like, a 32-processor system or whatever that seems like a really odd scenario. Do you end up with a situation where you could actually run code faster in the Virtual Server, like a single-threaded application, faster than it would run on, like, a single-CPU system? What I am trying to understand is, what’s the advantage of running 4 or 16 or whatever processors on your actual server if you are only seeing a single processor in Virtual Server?
Brian Randell: Well, that’s a great question. So understand this: At the end of the day, you have the host operating system, and then you have this program that is controlling the virtual machine, the controller. Think of it like the bios, the hardware of the real machine, okay? It has to transfer requests from the virtual machine guest operating system down to the real host operating system, which then tabulates to the real hardware. So it’s kind of like SMP scheduling, how you don’t instantly get double performance if you add an extra processor. By having multiple processors, more virtual machines have more CPU time, whereas if you want three VMs under Virtual PC, they have to share that same single, main thread of Virtual PC; so there are contingents, right? Usually, what happens is, people set their foreground VPC to have the most processing time. So it’s very much like, I think, Win16 almost, right? We’re in this very, you know, shared environment. With Virtual Server multiple processors, each virtual machine is acting more like a real independent machine, as opposed to a bunch of shared machines running together on the same resource.
Geoff Maciolek: So a big advantage would be where you are running Virtual Server and you have a Windows 95 box, a Windows NT 4.0 box or whatever running as guest operating systems. You have multiple guest operating systems running concurrently.
Brian Randell: Absolutely. That’s exactly what it’s for. For example, when I do my Team System talk, I have a domain controller, a data-tier box, an app-tier box, and a build-tier box. All are Virtual Server. And, again, I only have one processor; but Virtual Server multitasks better than Virtual PC does for that situation, especially since they are not interactive. They are all just sitting there running as servers. Now, granted, on my quad box, it’s even a much happier experience, because basically each virtual machine, when I only run four, gets its own dedicated processor, for all intents and purposes.
Richard Campbell: You know, the one thing I’ve always wished I could do with VPC is take an existing machine that’s directly installed on a drive and copy it into a VPC.
Carl Franklin: Yeah, that would be great. What a great idea.
Richard Campbell: You know what I mean? Like I want to practice the upgrade of an exchange server; so take the existing exchange server as it is, throw it in VPC, and run the…
Brian Randell: You can do that! You can totally do that!
Carl Franklin: How?
Brian Randell: Okay. It depends on how you want to before you go any further, I want to put out one little disclaimer here about when we talk about stuff.
What you can do with this software and what is supported by Microsoft are two different things. So for those of you that are in a corporate environment and might be thinking, “This is great stuff. I am going to get my IT shop to use this,” I thought I would put a couple things in context.
Virtual PC is designed for client operating systems; Virtual Server is designed for server operating systems, as far as production support. From a testing and development standpoint, Microsoft pretty much will support any Windows version in the contrasting operating systems.
Microsoft, when they bought Virtual PC from Kinetics and the virtual-server technology, decided that obviously they want to push Windows; so they had dropped support for everything but OS2 as a non-Windows operating system. However, at “In MS” a couple of weeks ago, they announced that they are going to be using third parties to support Linux and other x86-based operating systems. So the list of operating systems that are supported is much smaller compared to what will run on Virtual PC and Virtual Server.
So I want to get that out of the way as far as technology. The one operating system, by the way, that I know runs like complete crap and just don’t do it is Novell NetWare. The way Novell NetWare operates just is not compatible with the way Virtual PC and Virtual Server works, so just don’t even think about it.
Richard Campbell: Interesting. I have run Fedora Core2 version of Linux just fine under VPC.
Brian Randell: That’s just it. They will run fine. Now, there is one other thing we should talk about these operating systems.
Virtual Machines and Longhorn
Carl Franklin: Wait, wait, wait, hang on. What about Betas of Longhorn?
Brian Randell: I am going to address that, because I want to bring up one of the little tricks that make Virtual PC and Virtual Server work really well with Windows.
Because whenever we do virtualization to get better performance, they have you install something called the “Virtual Machine Additions”. These Virtual Machine Additions are highly tuned to current versions of Windows. In fact, you will notice when you are installing, for example, Windows XP SP2 that it can be dog slow in terms of the additions in it, and then all of a sudden, it’s like magic. The additions are very sensitive.
Well, the problem is, they currently do not have any public version of the additions that are available for Longhorn. Longhorn is probably the most painful experience in a virtual machine you will have next to Netware. Just say no. Buy yourself a second hard drive for your laptop or even a shuttle-type drive for your Desktop if you want to play with Longhorn and you don’t have an extra physical machine.
And the other thing is, understand: Longhorn’s hardware/software requirements right now are really high even for a lot of people with Desktops let alone trying to shove it into Virtual Machine and limit its RAM and its hard disk. So just don’t go there. It’s just a bad thing right now.
Richard Campbell: So friends don’t let friends run Longhorn in VPC.
Brian Randell: Not until Microsoft releases additions, and then we will see; but that will be a while, because Longhorn is not even into real Beta yet. It’s at that early adopter, you’re-a-sick-person-if-you-want-to-play-with-this kind of thing.
Carl Franklin: Get a hot, swappable, removable boot drive for that.
Richard Campbell: Or you’ve got a PC you really don’t like any more.
Carl Franklin: No, it should be a big one.
Brian Randell: But, no well, you don’t want to do that, because the problem is, “I’ll use my secondary, old machine,” which makes the experience worse, too.
Carl Franklin: Get a honkin’ machine.
Richard Campbell: Well, I’ve got a high-performance machine here that keeps catching fire, so it’s great for Longhorn.
Carl Franklin: It will just speed up the fire, that’s all.
Richard Campbell: We’ve got to get back to the important part, which is, “How am I going to get this existing drive that’s not VPC’d into a VPC?”
Brian Randell: There are two ways to do it, okay well, actually, three ways and it depends on do you want the supported way, or do you want the way Brian would do it, or what are you looking for?
Richard Campbell: You know I want how you would do it.
Brian Randell: Okay.
Richard Campbell: You know I do.
Brian Randell: First of all, Microsoft has its supported way to do it, which is good if you want existing servers and move them to Virtual Servers. It’s called the Virtual Server Migration Toolkit, it’s a free download, and it’s designed in particular to upgrade your Windows NT 4.0 boxes from physical hardware into a virtual machine.
Richard Campbell: Cool.
Brian Randell: Yes. Now, this is important, because, you, obviously, Richard, as the toy boy know this, and I am sure Carl and the rest of our listeners know this. Windows has some certain hardware dependencies, right? And you know how NT 4.0 worked, right? It was very sensitive to the HAL it ran on, as well as the peripherals. It didn’t support Plug and Play very well. To get it to run a laptop was somewhat of an art in the old era, right?
Richard Campbell: It was awful is what it was.
Brian Randell: Exactly. So now, you’re going to throw it into this new box. It’s not like XP, which just says, “Oh, there are new devices. I’ll Plug and Play and fix it and make it work.” They have to do some tuning, and they fix the HAL and make it work, especially if you are migrating off, say, a dual Prodigal/Pentium Pro Box, right? They have to map the old uni-processor HAL in. They do a lot of magic to make that work. That’s the way you should do it if you are trying to do this for production servers too, you know, maybe do consolidation: Virtual Server Migration Toolkit, VSMT for Virtual Server. Okay. That’s good and fine for production. Now, you want to screw around like this, okay, here is what you should do. Number one, use True Image, Drive Image whatever product you have for doing imaging Ghost.
Richard Campbell: Acronis, right?
Brian Randell: Back up your host machine first. Do that first, because you are going to have to reuse that image later. Now then, sys-prep that operating system if it’s not a domain controller. And when you do sys prep, there are different ways and levels of doing sys prep. The one way you’re going to do sys prep here is, you want to do the one where it tells it to look for hardware changes.
Richard Campbell: Yes.
Brian Randell: Okay, if it is a version of the operating system that supports this. Then, you image that one that you’ve sys-prepped, and then you go to Acronis True Image, have it image it onto your virtual hard drive. When you boot up the virtual hard drive, it will discover hardware, and you are ready to go.
Carl Franklin: No kidding.
Brian Randell: That’s the most compatible, safe way to do it without using VSMT.
Richard Campbell: Then you’ve got to restore the image on the original machine, so it’s back to what it was, right?
Brian Randell: Before the sys-prep.
Richard Campbell: So you are talking three, four hours to snap the image in the first place, another couple to restore it, plus the fiddle time in between. That’s not bad.
Brian Randell: It’s not that bad. In fact, you’ll love this. I actually did it recently. I was doing some tests with Virtual Server with the fixed hard-drive performance. So I actually tried the imaging there, and it worked great. In fact, it didn’t take that long to do a restore in the virtual machine. Under Acronis, they were able to do a full restore of about a 6-gigabyte hard drive, and it took it only about 12 minutes total.
Richard Campbell: Nice. Definitely, you want separate spindles for that.