Categories
Archives
August 25th, 2011
I don’t like Windows.
Unfortunately, I regularly use a few applications that require Windows.
Options (not requiring theft)
- Buy a dedicated Windows box – BAD (expensive, extra baggage)
- Dual-boot Windows on my Mac – BAD (don’t want to close OSX)
- Run a Windows VM inside OSX – OK (but ties me to my Mac and requires a license)
- Rent time on a hosted Windows box – GOOD (cheap, accessible from anywhere)
Where to Host
So I looked into hosting options. I was hoping for a pay-per-CPU plan, but it doesn’t seem like you can get a full shell/root install on those plans (they seem to be services that host applications rather than operating systems, e.g. Google App Engine).
That left me with the obvious choices: Rackspace and Amazon (and some small players that I didn’t investigate), both of whom offer Windows Server 2003 and 2008, both 32 or 64 bit.
Which OS
I went with Windows Server 2008 32 bit (assuming that 32-bit uses less resources than 64-bit on the underlying Citrix boxes and I’ll therefore get more bang for my buck – I have absolutely no idea if this is a fair assumption; would love feedback).
Pricing
Now, the cheapest usable plans for hosting Windows on either Rackspace or Amazon still cost you a lot of money (Rackspace: $58.40/mo. for a 1GB instance, which is the smallest on which you can run Windows; Amazon: $87.60/mo. for the standard “Small” on-demand instance).
NOTE: Amazon’s “Micro” on-demand instance runs you $21.90 per month, but I found it to be unusable for a Remote Desktop situation due to not having any guaranteed level of EC2 Compute Units (it bursts up to 2 EC2 Compute Units, but when that extra power isn’t available on your hardware, it lags desperately).
NOTE: You can also save money with Amazon by purchasing a Reserved Instance, which is basically an up-front fee following which you enjoy reduced hourly rates.
NOTE: With Amazon and Rackspace, you pay per instance hour. That’s the amount of time that your server exists (whether or not it’s online or powered off).
Clearly, I don’t want to spend over $50 per month just to run a couple applications. So…
The Solution
I decided to take a “when you need it” approach and create a server when I want to use it, then delete it when I’m done.
Kind of a pain, just to run some Windows apps? Yeah, but with the extensive APIs provided by Amazon and Rackspace, it’s all just a Perl script away.
Getting off the Fence
Rackspace or Amazon?
I settled on Amazon because of their EBS (Elastic Block Storage) offering. It’s like NAS for the cloud. Rackspace doesn’t offer block-level storage right now, and while you could hack together a virtual drive that stores your files away in CloudFiles, why bother. Amazon has all the tools.
Specifics
So here’s the big idea.
- Create an EBS volume. This is where your data will live. Think of it as an external hard drive that lives in the cloud. Every time you’re done using your ephemeral Windows instance, you’re basically throwing your computer out the window, but hanging onto that drive so you can plug it into a new computer next time. You’ll probably need to set up a security group, key pair, etc. if this is the first time you’ve used Windows with EC2.
- Ensure that you can successfully Remote Desktop to your new instance’s public IP address. Everything following assumes that you can. If not, stop here and work it out.
- Build an EC2 instance from one of Amazon’s Windows images (an “AMI”). NOTE: When you do this, Amazon will automatically create a second EBS volume to host this instance. This second volume is ephemeral and will die when you terminate your server instance. That’s why we don’t store anything on it! Store data that you care about on the EBS volume that you just manually created, as it will persist whereas EC2 ephemeral disks will not.
- Attach the EBS volume that you created to your Windows instance. The first time you do this, you’ll need to format it.
- Tweak the OS to be how you like it (Windows updates, security settings, etc.)
- Install your apps. Ensure that you tell the apps to store their data on your EBS volume (which for me appears as the D: drive). For example, the Quicken application is installed on my Windows instance (technically on the 30GB ephemeral EBS volume “backing” my Windows instance: the one that Amazon magically created) whereas my Quicken data resides on my persistent EBS volume.
- Detach your EBS volume from your instance (otherwise, Amazon will make a copy of it when you generate an AMI from your instance, but we don’t want that; we want to use the same EBS volume to persist data across instances).
- Generate an AMI from your instance.
OK, now you’re pretty much set up.
Usage
When you want to use Windows:
- Start an instance of your AMI
- Attach your EBS volume to the AMI.
When you’re done using Windows:
- Shut down and terminate your instance (the EBS volume will auto-detach)
Enhancements
Wait, didn’t I say something about a Perl script?
Yep: http://pastebin.com/gwu6834M
Replace the “xxx” in the variables near the top, then run it. This assumes you:
- Have the EC2 API tools (get them from Amazon’s site)
- Have configured your system such that the EC2 API tools work (e.g. I had to add “export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home” to my .bash_profile)
- Have generated, downloaded, and exported EC2_PRIVATE_KEY and EC2_CERT variables pointing to your Amazon X.509 certificate and private key.
You’ll notice some domain name and IP address stuff in the Perl script. Just comment it out if you don’t have a domain name that you want to point to your windows instance. However, it’s useful! To use this:
- Allocate an Amazon Elastic IP Address
- Point a domain name to this IP address
Now when you run the Perl file:
- An instance will be started from your AMI
- Your EBS volume will be attached to the instance (and a snapshot will be taken)
- Your elastic IP address will be associated with the instance
Remote Desktop to your Windows address and you’re all set! Shut down the computer when you’re done, and all clean-up will happen automatically (instance termination, EBS volume detachment, elastic IP disassociation).
NOTE: the Perl script specifies that your instance should terminate (rather than stop) when you shut down Windows internally. That allows us to tear it all down by just using the Windows regular shutdown method, instead of using the Amazon web interface or API.
April 4th, 2011
Seems to be 6299 (6300 fails).
