Building a Cloud OS for .NET Developers – Part 2

In Part 1 of my Building a Cloud OS for .NET Developers series, I talked about setting up a pure cloud OS focused on developers. But the one crucial aspect I left out was the developer tools.

In this second installment, we’ll be covering exactly that. How do we manage having Visual Studio and associated tools and servers universally accessible in the cloud, even on mobile devices such as iPads?

We’ll start with the king of the cloud:

Amazon Elastic Compute Cloud (Amazon EC2)
http://aws.amazon.com/ec2/

At EC2 we can create a variety of Windows instances, get full admin access via remote desktop, and install anything we want (Visual Studio, SQL Server, MongoDB, etc). We can also run these for just 30 minutes here, 2 hours there and we’ll only be charge for the time we use it.

We are going to setup a Windows Server in EC2 which we can access from our Cloud OS, or any other machine or mobile device, and deck it out with all the developer tools we want. You have to choose your server type based on what you’re planning on doing as well as how much you want to pay. Here are the available options and pricing. You can roughly expect to pay $0.50/hr for a good workstation, or $0.12/hr for an acceptable but small one.

Amazon EC2 Instance Types: http://aws.amazon.com/ec2/instance-types/
Amazon EC2 Pricing: http://aws.amazon.com/ec2/pricing/

I’m currently using a Micro Instance for an SVN server which is always running as well as High-Memory Extra Large Instance for my development machine that I start and stop on-demand when I need to get some programming done. Here are the specs for the developer workstation:

High-Memory Extra Large Instance

17.1 GB of memory
6.5 EC2 Compute Units (2 virtual cores with 3.25 EC2 Compute Units each)
420 GB of instance storage
64-bit platform
I/O Performance: Moderate
API name: m2.xlarge

You have to admit, that’s a pretty killer workstation. It’s a overkill on the memory, but has better processors than the cheaper ones which also have decent memory.

The price of the dev machine is $0.69 / hour. I’ve also built some tools which help shut down the machine in case I get distracted. So far I’ve been using it pretty heavily this past few weeks and have spent probably $13 on it. That’s not bad for the possibility of being anywhere in the world (with an Internet connection) and getting my workstation running in an instant. OK, maybe it takes longer than an instant. To be fair, it usually it’s 10-15 seconds :).

Take the Free Lunch

One thing you should do straight away if you’re going to try this is sign up for the EC2 Free Tier:

AWS Free Usage Tier
http://aws.amazon.com/free/

This won’t cover the EC2 CPU time (that’s Linux only), but it will cover storage, bandwidth, S3 snapshots, etc. You also get a free Linux machine to play with if you like.

Setting up Windows in the Cloud

OK, so if you’re chosen an instance type and are ready to start, you should do the EC2 walk-through I put together here to get your machine up and running and login for the first time.

Building Windows Machines in Amazon EC2
http://www.michaelckennedy.net/blog/2010/01/31/BuildingWindowsMachinesInAmazonEC2.aspx

I’d guess that takes about 15 minutes. When you’re done, come back here…

Installing Software in EC2 and Windows

So you’ve logged in and you want to install Visual Studio, SQL Server, and other MSDN goodies. The easiest way to get them is to use the ISO DVD images from the MSDN download site. In order to mount them on your EC2 machine (which has no DVD drive), you should install

Virtual CloneDrive
http://www.slysoft.com/en/virtual-clonedrive.html

which lets you mount ISO images as if they were proper DVD drives. Then you can download and install all the MSDN files you need. A good place to start is with Visual Studio:

Microsoft Visual Studio 2010 Premium Trial – ISO
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=f81412a2-d48e-4040-9b32-27eaf771c5db&displaylang=en

One word of warning here: I’ve noticed that Chrome can freak out and fail to download very large files inside your EC2 instance. Don’t know why, but it does. So be sure to use IE or Firefox to do the downloads for the ISOs.

Syncing your Files Between your Local Machine and Dev EC2 Machine

There are two techniques we can use to sync files, depending on what category of files we’re sharing and how. For the source files, you can always setup an SVN Server (that’s what my micro instance is about). I’m a fan of Visual SVN. It’s free and easy to setup and admin.

VISUALSVN SERVER
http://www.visualsvn.com/server/

Then on your EC2 dev machine (and your others you may have) setup:

TortoiseSVN
http://tortoisesvn.net/

and

AnkhSVN for Visual Studio Integration
http://ankhsvn.open.collab.net/

Then you have super easy, reliable, and secure sharing of your source files.

For everything else, you can just setup a Dropbox share between your Cloud OS and you EC2 Dev Machine:

If you don’t have Dropbox and want to try it, use this link to create an account

http://db.tt/Qo7m9PA

and you’ll get me some extra free space which I always appreciate. :) Then if you have a file on your local computer you want accessible on your cloud dev machine, just drop it in your Dropbox folder on the originating computer and it’ll be there as soon as it uploads.

Waste Not, Want Not

Now here is a problem you will encounter:

You’re working on your dev machine in EC2, something comes up and you get distracted and forget about it for the rest of the day. When you come back the next day you see your EC2 system is still running and you’ve wasted $12 by leaving it running idle overnight. That sucks. If it happens on Friday, it might run the whole weekend which is even worse.

To avoid this, I wrote a little tray utility that watches for extended idle times and will shutdown your EC2 instance if it’s idle for too long.

Below is how you configure it. Simple, right?


Add it to your startup menu to make sure it starts when you log in.

You can download it here. I may blog about this app in greater detail later, for now feel free to use it.

Shutdown on Idle
ShutdownAfterIdle.zip

Reliable Access to EC2

One annoyance in EC2 is that every time you turn off your EC2 computer, it will take on a new random public DNS name. If you really want to access to your EC2 machine from anywhere, you probably want a reliable DNS name / IP address. That’s where Elastic IPs come into play in EC2:

Feature Guide: Amazon EC2 Elastic IP Addresses
http://aws.amazon.com/articles/1346

If you create an elastic IP, then you can map it to a sub-domain in your domain and always use that. For example I could register it for cloud-developer.michaelckennedy.net. Then as long as I have a way to start my machine and re-associate the IP, all my config on my various machines (such as remembered RDP settings and passwords and such) will “stick”.

Be aware that while your EC2 machine is off, you’ll be charged a small fee (few dollars / month) for the address. You can decide whether it’s worth the trouble to save the few dollars.

Mobile / iPad Access

I’m sure when you think of accessing your EC2 dev machines, you’re thinking of doing that form Windows or maybe a Mac (using  http://www.microsoft.com/mac/remote-desktop-client). But the iPad (and even the iPhone) has apps to allow you to use Remote Desktop to EC2. For example, here’s editing the code for http://chatpast.com in Visual Studio via my iPad:


(click for full size image)

And you can even bring up the keyboard or attach a Bluetooth keyboard.


(click for full size image)

The app I was using is called “Jump”, and you can find it here:

Jump for iPad
http://jumpdesktop.com/

Summary

I hope that gives you some inspiration to try a new way to work in the cloud. You saw that we can create fairly serious EC2 Windows computers which can serve as developer workstations. We can share files via source control and Dropbox and we can access the computers from Windows, from Macs, and even mobile devices like an iPad.

Good luck!
@mkennedy

12 comments

  • Hi Michael, I found your posts on EC2 very helpful. However, I’m a little confused as to how the instance storage works. I created a size-large Windows 2008 R2 server, and was able to download and install VS 2010 from MSDN, but halfway through downloading the ISO for SQL Server, it conked out and said the disk was full. Turns out though it advertised 850 GB of storage, it only had 30 GB. Did I miss a step? Thanks.

  • Also, for anyone else new to this, if you clicked through on the Elastic IP link, you don’t have to write your own API script to associate the IP address with your instance. The UI in the EC2 console makes it very easy.

  • I can testify to the importance of the inactivity shutdown app. I typically work 9-10 hours throughout the day, but will start the virt in the morning and shut it down at bedtime, so I’m billed for more than 15 hrs. It’s important to log off if you’re not using it just like turning off the lights when you leave the room, and not leaving the faucet running. Trick about the tray app is setting it up to auto-start in Windows 2008 r2 using Task Manager. In my case, I set it up to run on system startup, because I’ve been known to start the server but forget to assign the Elastic IP and log in.

    Also, here are the steps to expand your C: drive: http://barriquesoft.com/?p=19

  • On second thought… If you run it on system startup, its process is in a different session than the one you will have via RDP, and it will appear to be idle and shut down even if you’re not :-(

  • Hi, Michael, I found your post is very useful to set up a cloud development environment since I consider to set up one. when you use RDP to access VM and write your code in Visual Studio, do you feel any lag/delay on screen? when auto shutdown app to shutdown VM, can it auto save the code in visual studio? thanks in advance.

    • Hi, thanks! Visual Studio is usually pretty responsive provided you have a good network connection. Not necessarily something to try via a coffee shop but was fine over broadband.

      As for the auto shutdown, no. It just exits but VS does do recovery. You could grab the source and have it find all VS windows and send CTRL-SHIFT-S keys to them first. :) If you do, please share!

      Good luck,
      Michael

      • Thank you! Michael, The reason of setting up cloud-based development environment is not only can I write the code anywhere , but also prevent others from stealing my code. do you have other ideas to prevent code leaking from laptop/desktop? I use visualonline and visual studio 2013, but one copy of source code still exists on laptop, if laptop is stolen, then all source codes are leaking.

Submit a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s