Tcoz Tech Wire

Discoursing on trends and technologies interesting to Tim Consolazio, sole proprietor of Tcoz Tech Services, specializing in Flash/Flex/Air, iPhone, Facebook, Twitter, and related technologies.

"Technology from an indie software developer's perspective".

Monday, June 1, 2009

Flash Flex on the iPhone? Setting up the Amazon Cloud Instance running Citrix XenApps

This is a continuation to my series of articles detailing how to get Flash Apps running on an iPhone...sort of. You really don't run Flash on the iPhone, you run it on a Citrix XenApps server, which runs on a Windows instance in the Amazon EC2 cloud.

My previous blog articles can be found here:

- Flash, Flex...on your iPhone?
- Monday, May 18, 2009 The Citrix Receiver Follow Up: Flash/Flex (and then some) on your iPhone...or Symbian...or WinMo...or...

Quick blurbs on what the technologies I mention above are:

- Flash/Flex/Air: if you're reading this article, no explanation needed.
- Citrix, simply, specializes in terminal-based delivery of applications. Think "thin client" delivery of applications.
- XenApps, in there own words, "Citrix XenApp virtualizes an individual application, be it Microsoft Office, PowerPoint, Excel, or SAP (sic, or Flash, etc.), allowing users to run those applications on a client directly from a XenApp server hosted with a Windows application."
- Amazon EC2, cloud-based computing infrastructure. I describe this more below.

So, my goal is to "Deliver Flash/Flex/Air apps, initially for the iPhone but eventually for any client, from the EC2 cloud running an instance of a Windows Server running Citrix' XenApps".

Whew. I could probably land a contract just by saying I know what that means.

In order to get this rolling, I'll have to get a Citrix XenApps instance running in the on the Amazon EC2 cloud. Citrix offers a video showing how to do this, you can view it here.

Three IMPORTANT notes, this is fair warning, and this is coming from somebody that has worked with resources in clouds before (I've just never been responsible for actually configuring and maintaining one).

- WATCH THE WHOLE VIDEO CAREFULLY. Believe me, you won't figure it out on your own if you've never done anything like this before.
- DO NOT SKIP THE VIDEO IN FAVOR OF THE "STEP BY STEP" IMAGES BELOW THE VIDEO. They don't provide enough detail.
- DO NOT USE SAFARI. If you're a Mac user, you probably know Safari doesn't always work well in sites that have multiple form submissions. The Amazon web pages broke quite a bit until I switched to Firefox.

Let's talk about what "an instance in the EC2 cloud" means. An "instance", is conceptually like a dedicated server...but it's not. It's an allocation of resources that appears to me to be a server, but which is disposable; when you terminate an instance, it's configuration is saved so you can restart it, but otherwise, the resources are freed up. The company, like Amazon, uses commodity hardware to build a platform to make instances available, and you pay for the time that each of your instances runs, because you're using resources in their cloud. When I terminate the instance, I don't get billed anymore, because there's no server to keep up and running, just a stored configuration that gets reconstituted into an instance if and when I start it back up.

Conceptually, the "cloud" is like a big ball of clay. When I need a chunk of clay, I grab off as big a handful as I need; I pay for that chunk based on the size of it, and how long I keep it out of the main big ball. When I'm done, I take a snapshot of the chunk, and just put it back onto the big ball. It's now available for anybody else to use, and my billing stops until I grab a new chunk, which by using my snapshot, can get instantly reshaped to the last known configuration. I can grab as many chunks as I need, shape them all differently, and so on.

It's a great model. In addition to a website hosted by Brinkster (where my blog and main site is), I currently pay almost $150 a month for a dedicated Windows server that I use for deployment and testing of customer apps. I pay for it whether or not I'm actually doing anything with it, which has irked me more than once. It's a business write off and all that, and IMHO an essential tool for any independent web-based software developer, but still, if I can economize by just using cloud instances of windows and linux servers, activating and deactivating them when I actually need them, and enjoy the easy flexibility of multiple environments (this one runs Tomcat on Linux...this one .Net on Windows Server 2008, etc.) I can cut that cost to a fraction and save myself multiple webserver config headaches and such.

Anyway, to get started, you go to the Amazon Elastic Compute Cloud EC2 Site. Initially, this is a little scary, because you see a list of usage fees by the hour, and you have to submit a credit card. But I'm intrepid, and have a business credit card, so on I go. I needed to set up an EC2 account, which lets me run select all kinds of pre-made server images that I can run as instances, and an Amazon S3 account, which is the storage mechanism for my files and so forth. They run independently of one another; again, remember that you're not actually running a server, you're running an allocation of resources, broken down into processing and storage. This way, I can run the same image as multiple instances, each with different (or differently configured) apps, using different amounts of processing power, all pointed at the same storage, or different areas of storage. Very flexible and elegant.

Anyway, the EC2 account I want to run my server images in is "$0.125 per Small Windows Instance (m1.small) instance-hour (or partial hour)". According to the documentation, it breaks down like this:

- You're paying by the hour, 12.5 cents, for every hour your instance is running. Hmm...let's assume I'll leave it up all day for a month: 12.5 x 24 = 300 cents = three bucks a day, x 30 = 90 bucks a month. I don't mind that as an investment in learning this technology and proving its use; if I land one contract because of this, it'll more than repay me in a couple of hours. And if course, I don't have to run it all the time.

- The specs for a Small Windows Instance, which should be plenty for my development experiments and demos: 1.7 GB of memory, 1 EC2 Compute Unit (1 virtual core with 1 EC2 Compute Unit), 160 GB of instance storage, 32-bit platform. Hmmm...we'll have to see how it goes. The large instance has 7.5 GB or memory, but is fifty cents an hour. So, here's hoping the Small Windows Instance can swing it.

So, you fill out the forms (again, don't use Safari), which when complete, takes me to a page with the following message:

"Thank you for signing up for Amazon Elastic Compute Cloud. We will e-mail you a confirmation when the web services are available for you to use. In order to begin using this service, you will need a X.509 certificate. You can Create a New X.509 Certificate or Upload Your X.509 Certificate."

Ok...so let's create the X.509 Certificate. If you don't know what one is, an X.509 certificate binds a name to a public key value; more generally, a public-key certificate is a digitally signed statement from one entity, saying that the public key (and some other information) of another entity has some specific value. So, by using a certificate, a browser and an application know that they are speaking to the intended targets by comparing those values; if it checks out, the communication is coming and going from where it's supposed to.

After a minute or so to create the certificate, I now have a certificate assoicated with my EC2 account, and my instances will be run using it.

That really seemed to be about all there was to it; strangely enough, by signing up for EC2, I seemed to have already signed up for S3; I went to the S3 page to sign up, but it told me I already had access, and as far as I know, I've never signed up for it before. It makes sense, but seemed a little implicit; I'd prefer to have at least received an explicit notice of some kind. It doesn't seem to cost me any additional money though.

Once that's done, you go to the EC2 Console and look up an image of the XenApps demo image. This image is located in the Community AMIs list after you click "Launch Instances" (search for "XenApps"). In order to do so, you'll need to create a security group and a key under which to run the instance; these items do things like open ports so that you can access the instance however you need, like HTTP, RDP, and via the Citrix clients. WATCH THE VIDEO, it explains exactly how to do this and what it means.

All in all, not so bad to get this end of it up and running. I still need to know how to upload and configure apps to make them available, but that's the next step. For now, I'm an independent developer with direct experience in setting up custom configured server instances in a cloud. I understand the benefit of it and can put out a wide number of configurations for any kind of client to access and test applications, and it's costing me twelve-and-a-half cents an hour to play with. Worth every penny IMHO.

Next, making Flash/Flex/Air apps available on my fancy new server instance running XenApps.

As always, thanks for visiting.

Labels: , , , , , , , , , , ,

0 Comments:

Post a Comment

<< Home