Friday, April 6, 2012

Thoughts On Virtualization For SharePoint 2010 Development

Chris Domino, Director, Enterprise Architect

Being a SharePoint developer, I've always run Windows Server natively. From the timeframes of 2003, 2003 R2, 2008, and 2008 R2, I've gotten very used to having gray task bars, typing "sldkjf" into the Shut Down Tracker, and spending lots of time getting wireless and sound to work. There are a lot of resources out there that discuss how to turn Windows Server into a client operating system, going beyond configuring Aero and hacking the Zune setup to install in an unsupported environment.

What I was more interested in was the development experience. Despite the fact that SharePoint 2010 installs, to a limited extent, on Windows 7, I still think that the best development experience is to run server native, and have the full platform and API available to Visual Studio. At the end of the day, you still have Visual Studio and SharePoint installed on the same machine, so why not work with the full features of each?

The alternative of course is virtualization. VMs are great, since you can quickly tear down and tear up server environments pre-packaged with SQL Server, Visual Studio, and all of the SharePoint configuration you require. An interesting corollary to this is that you therefore don't need to reinstall or reinstate Office, other apps, personal files, preferences, etc. every time you hose your box; Email, music, etc. all rock out on your host machine, leaving your VM a lean server environment that could exactly match production.

But there are a few downsides; in my opinion, they sort of outweigh the many upsides. The main one is performance. I love multitasking, and when I'm building out SharePoint sites, there are a lot times when I'm waiting thirty seconds to possibly thirty minutes for IIS to reset, PowerShell scripts to run, sites to spin up and warm up, etc. Those are perfect opportunities to pop into a different instance of Visual Studio and kill a bug or implement a quick feature.

I've found that having a full SharePoint farm running as a web garden on a single physical machine combined with multiple Visual Studios running combined with Outlook, OneNote, Zune, and everything else, things get SLOW. Now virtualize the processor. Now virtualize the hard drive, memory, NIC, etc. Now throw in the overhead of virtualization itself. Yikes. Or, more appropriately: Yawn!

Now if you're on three concurrent SharePoint projects (bless your soul) and need to be able to support three separate farms, the choice to use VMs is sort of made for you. But when it comes to the standard day-to-day doings of a developer, the performance hit is really felt hard. But performance, in terms of hardware (physical or virtual) throughout, is only part of the picture. The other knock I have against living in a virtual world isn't exactly "performance," per say, but "code speed."

I can fly through web development in Visual Studio when I have two monitors, a few extra CPU cores laying around, and a local database. It's not that you can't achieve this with virtualization technology, particularly around multiple monitors; the two technologies I've used, VirtualBox and Hyper-V, can basically get there. (VirtualBox fakes this by having two separate windows that can talk to each other. With Hyper-V running locally, I can remote into the machine with RDP's "Use all my monitors for the remote session" option enabled.)

But it's not the same!

Both setups are "tweaky." Whenever I'm remoted into a server, it never exactly quite feels seamless. There are ever so slight delays in mouse clicks and keystrokes. Or the connection would drop and reset itself. Or the screen would hiccup while repainting and I'd end up opening something twice. Or I'd accidentally control + alt + delete or alt + tab my way into a confusing state.

When using a local VM, my internet connections get screwy. I need to adjust them whenever I'm in a new office or connected to a new wireless or wired network. (And it's quite annoying to have my tray network icon constantly displaying the yellow-warning-exclamation-marked-triangle overlay.) You also lose the file copy-and-paste you get with RDP. Beyond that, there are paradigm shifts for things like hibernation and screen locking that just make my development experience a bit clunkier.

In both scenarios, there are setups I've configured that basically keep me as technically productive as a native development environment, in terms of how long it would take me to complete a given task. However, I don't fly. My code speed is noticeably lessened, and beyond not physically being able to type and compile the same about of code, it's a distraction that steals away some of the cycles from my own CPU (my brain).

This might sound minuet and over-cerebral, but attitude plays a huge role in my work. Technology should be making us more productive, not less; that's the whole reason my career exists. When I boot up and click the Visual Studio icon in my task bar, and don't immediately see the splash screen, I become frustrated, click it again, and end up waiting even longer while both instances of the application launch only to have to close one - which still takes over a minute while my virtual or remote machine warms up elsewhere.

By then it's 9:20, I'm already off my game, and haven't even started working yet.

But I think I've reached a happy place that combines the pros of all of the above environments (native SharePoint / Visual Studio, virtualization, RDP, and having a host client operating system) while mitigating the cons as much as possible. That happy place is Windows 8. (Note: this was written while running Windows 8 Consumer Preview; things might change when the platform RTMs.)

Having been a Windows Phone 7 user since the day it launched, Windows 8 wasn't as big a shift for me as it will be for PC folks not familiar with Metro. But I don't want to write about Windows 8 overall; this is instead focusing on the introduction of Hyper-V to the client, which is a wonderful enhancement. VirtualBox, until now, edged Hyper-V out with client OS support. What I want to discuss here is my exploration into virtualization on the Microsoft stack from the perspective of a SharePoint developer.

The first task was getting my host environment installed. I had been running Windows Server 2008 R2 natively for quite a while. Then my hard drive crashed...literally...into the my laptop fell from my hand while walking to a meeting. I decided that this would be a great opportunity to kick around not only the beta of the new client OS, but also a new SharePoint development paradigm. After getting a new hard drive for my Lenovo T510, I installed Windows 8 from a USB drive on a new partition.

Once it was installed, after spending a few minutes figuring out how to get into Control Panel, the next thing I did was go and enable Hyper-V in Windows Features. There are two: "Hyper-V Management Tools" and "Hyper-V Platform." The issue I ran into was the latter being disabled. I didn't panic though: CPU virtualization was probably turned off in my BIOS. So I rebooted and into the BIOS, found the proper screen, and then panicked:

It was already enabled! I didn't know what the "Intel VT-d Feature" was, but I decided to enable it anyway, as it could be a component to the CPUs virtualization infrastructure that Hyper-V depends on. Then I rebooted and checked the features again; Hyper-V was still disabled. Already calculating how much more downtime I'd have to burn through installing Windows Server 2008 R2 again, I went to Lenovo's site and starting downloading and installing all BIOS, chipset, and Intel drivers I could get for my T510.

Fortunately, after flashing the BIOS, I was able to finish installing Hyper-V. Unfortunately, in my frantic "I CAN'T WORK" state, I didn't keep track of which updates I installed. I'm almost certain it was the BIOS update, but I can't know for sure. Regardless, I had native virtualization on my native client machine, and was ready to rock.

After standing up a new VM with all the normal trimmings, I installed Windows Server 2008 R2, SQL Server 2008 R2, SharePoint 2010 Enterprise, and Visual Studio 2010 Premier, along with all services packs and droppings from Windows Update. My machine has eight gigs of RAM, and I allocated the maximum allowed amount, five, to the VM. (Let the record show that I did not review or implement any of the Tech-Net Hyper-V performance optimizations, since my set up was so basic. The only other step I performed was creating a Virtual Switch so that I could share my NICs with the VM.

Setting up a virtual network is still something I don't completely have my head around. Why I have to look at this all day still vexes me:

And the fact that wireless works fine at the office but only for my VM at home (that's right: Internet access on the VM but blackout on my host) is even more annoying. Even though it's certainly possible to work without Internet access, the main reason I want it up for both is to be able to remote from host to VM. And I think it does; I've gotten it to work at home, meaning that VM needs to be online "enough" for it to respond to RDP calls, and the host has to also be online "enough" to think it can send them.

But getting proper RDP is worth it. Hyper-V comes with a connection mechanism, but it has crappy "full screen" support. Compare working in:


I know those screen shots aren't great, but it shows you how much real estate you can get with an RDP connection. Once I got past all of this, I was able to really get into a SharePoint development groove. However you do it, having Visual Studio (along with CKS Dev) installed on your SharePoint box is basically a must: quick deploys, copy to root, and better SPMetal support are features I cannot live without. Like I said, it's going to be slower than a bare metal installation, but in addition to a fully functional server environment, I also have a client to run the rest of my apps.

To that point, using Windows 8 beta with the remaining three gigs of RAM while a VM is running with the rest isn't awesome. But it is passable, especially since all my work (Visual Studio, SQL Server, and IIS) is not taking up any of that memory. I typically have a few Office apps, Lync, Zune, and probably a Visual Studio running (like I could possibly stand up an OS without my IDE) and it's not bad.

But like I said, it's not awesome either.

So I'm going to give this a try for a few months. The lock screen crashes. The networking is not 100%. Restarting hangs occasionally. But to date, Windows 8 (beta) with Hyper-V is the most evolved development environment I've had for SharePoint. The best part is, when I'm not developing in SharePoint, it's off; I can dev in my host environment and it's super speedy. (I have heretofore failed to mention that Windows 8, when not babysitting a VM or being a beta brat, is freaking fast.) Also, I owe it to myself (and my readers...and probably Microsoft) to bone up on some Hyper-V best practices, because I might be able to squeeze even better performance out of it.