Why is Windows Azure Deployment Slow Compared to Heroku?

Saturday, January 28 2012         No Comments

Earlier this month I got an email from a friend of mine who was trying out the Tutorial of running Node.js on Windows Azure. He had gotten to the point where he was deploying the code to Azure using the PowerShell command and was surprised to see it taking several minutes (like about 10). Having been using Heroku for some of his other work he thought he might be doing something wrong since deployments to Heroku takes only a few seconds ("with typing" as he put it).

So, why does it take so long to deploy to Windows Azure when Heroku only takes seconds? It has to do with the differences between the two platforms. Both Heroku and Windows Azure are Platform as a Service (PaaS) providers, meaning they abstract a large portion of their infrastructure away from you so that all you need to focus on is the application code and data, but the two platforms have different levels of abstraction.


Let's start with Heroku. First off, I'm not a Heroku expert. What follows is my understanding of the Heroku platform and how it works based on some conversations I've had, a presentation I attended by James Ward, research from their site and other articles. If I get something wrong, please let me know in the comments. Also, cloud computing platforms advance and change at an amazing pace, so what's written in this post is as of the time of it's posting. If you are reading this six months after it's posted the landscape may look a lot different.

The Heroku platform runs on Linux machines that have their resources partitioned by the open source resource partitioning layer LCX. This partitioning scheme breaks up the machines into what Heroku has termed "dynos". A dyno is a compute unit and the unit in which you are billed. You can think of them as "instances" of your application. They are completely isolated from one another so as to ensure that there is no sharing of data between the different dynos that may be running on the same physical server. A dyno has a set of resources dedicated to it from the physical server, so it gets a slice of CPU cycles, the disk subsystem, network IO, etc.
 
When you deploy an application to Heroku it gets packaged into what is called a "slug" (you can upload pure code to Heroku and let the platform compile it for you, or you can upload compiled bits, but either way a slug gets created and this is the internal package that Heroku uses to deploy to dynos). When a slug is deployed to a dyno the Heroku Dyno Manifold (the controlling software of all deployments and resourcing in the Heroku environment) finds a physical server, or servers if you are deploying multiple instances, that has available dynos and it drops the slug into it/them. Basically, they are copying your slug (deployable code) onto a machine that is already running and calling a process to start up. This is obviously pretty quick because the time is mostly in copying the code and the process start up. This is why you see average deployment times in the seconds for Heroku.
 
Now let's look at how Windows Azure works. The deployment unit to Windows Azure is a package file, which contains your compiled code and/or files. This is basically a zip file and probably not too much unlike the slug file used by Heroku. When you perform a deployment the package file is uploaded and the Windows Azure Fabric Controllers (the equivalent of the Dyno Manifold in Heroku) inspects the service definition file included in the package to determine the compute resources the deployment needs. The Fabric Controllers then select a physical server, or servers if you are deploying multiple instances, that has space on it for the deployment. A full virtual machine is brought up on the target physical servers and then your code is deployed to that VM as well. So, unlike the dynos in Heroku the virtual machines in Windows Azure aren't already fully running just ready for code (the host machines likely are). This is the case because as you are assigned a virtual machine in Windows Azure rather than just a process and you have a lot more control over that virtual machine. For example, you may run start up commands to configure the IIS server with something non-standard, or you may need to register 3rd party components before the system responds to traffic.  The abstraction Windows Azure provides starts at the Virutal Machine layer, where for Heroku the abstraction is down to the process.
 
In short, you could compare the differences between Heroku and Windows Azure deployments by thinking of Heroku as copying code to an already running machine and starting a process vs. spinning up a full virtual machine from a stopped state and then copying the code. Obviously, one is going to take longer than the other. This is why my friend was seeing a deployment to Windows Azure taking about 10 minutes. Either way, this is still faster than you can procure a server for deployment in a non-cloud environment.
 
So, if you were just looking at deployment times between the platforms Heroku wins hands down, but just as with all choices in cloud computing you have to be aware of what the differences are in order to make the right decision for your application. The approach that Heroku has taken is on the higher end of the PaaS model where they are abstracting the idea of Virtual Machines and servers as a whole away from you. Windows Azure abstracts away the infrastructure, but still provides you a lot more control over the virtual machine your application code is running on. So, for our discussion here, we are trading speed for control. Just like if you decided to use a full on Infrastructure as a Service (IaaS) provider (like EC2 instances from Amazon which Heroku actually runs on) instead of a PaaS provider you are trading less configuration and infrastructure concerns in the PaaS world for a LOT more control over your environment and infrastructure in the IaaS world.
 
My friend said he spent a few hours trying to research why there was such a discrepancy in deployment times between the platforms Hopefully this post will save others time in the future.
 

UPDATE: Added presentation by James Ward to my list of Heroku research. Thanks for coming to Cincy!

Interested in SQL 2012?

Thursday, November 17 2011         No Comments

There is an event on Tuesday, December 6th at the Microsoft Office in Mason, OH to give some insight into what’s coming in SQL Server 2012.

Check it out and register at http://www.thinksis.com/events_SQL2012cincy.php

Windows Azure SDK for Nov 2011 Released

Tuesday, November 15 2011         No Comments

I tweeted about this yesterday, but for those of you following the blog, Microsoft has released a new Windows Azure SDK along with a new HPC (High Performance Computing) Scheduler SDK and Windows Azure Platform Training Kit.

One of the great new features of this SDK and Visual Studio Tools is the simplified deployment.  Now there is a way to get a publishing settings file which will reduce the number of steps necessary to do deployments from Visual Studio.  These settings can then be shared across developers so that the same management certificate is used.  It will definitely make things a lot easier to get going with Windows Azure, just be careful that when you get a publisher setting from the management portal and allow the management certificate to be created for you it can add it to all of your hosted services across multiple subscriptions.  If you are a co-admin on several subscriptions, this may not be the desired effect. 

There are several new features other than just simplified deployments for Visual Studio.  For example, via Visual Studio you can now create Hosted Services and Storage accounts without going to the portal.  Check it out the official blog post for more information and get the update via the Web Platform Installer.

The more things change, the more they stay the same

Friday, November 11 2011         4 Comments

Several months back I posted about a change happening in my life.  I was changing jobs from a great local consulting company to a service company focusing on Windows Azure.  Prior to the change I had been working at the same client for over six years, a financial services company in Mason, OH. 

Have you ever really wanted something, only to get it and realize it wasn’t what you needed?  In my career that’s happened twice now.  Straight out of college I was in law enforcement (yeah, not computer science… my degree is actually in Police Administration).  I was a police officer for a city in Northern Kentucky for a very short time.  Long enough to go through the academy and get about a third of the way through my field training.  One day it just hit me that this career path wasn’t good for me.  Several weeks went by and nothing got better, so I resigned.  I left not knowing what I would do instead, until I got a job that was somewhat computer related for state University.

Back in June I went to work for a Cloud Computing services company focusing on Windows Azure, which is what I’d been playing with in my own time anyway.  I loved teaching Windows Azure technology to folks through the Windows Azure Boot Camps.  The job I was going to would let me focus completely on only Windows Azure projects.  Part of my role was going to be evangelizing the platform, which meant going to conferences to give presentations (which I also love doing).  It was everything I was looking for at the time, exactly what I wanted.  Sadly, it wasn’t what I needed.

So, for the second time in my career I found that I was doing something that wasn’t good for me for a variety of reasons.  The job was exactly as described for the most part and the projects were pretty interesting.  It just wasn’t what I needed to be doing.  This last Wednesday was my last day.

What am I going to do now?  Well, as the title of this post implies, the more things change the more they stay the same.  No, I’m not going to back to the consulting company (though I would if I wanted to get back to consulting).  I have instead signed on to the financial services company that was my client for many years.  I’ve been very happy to see them grow over that time and have been impressed with how passionately they’ve adopted agile methodologies.  They have complete buy in for agile from the top down.  The business is loving it and the developers are reaping the benefits of a great working environment.  I’m looking forward to getting started on Monday.

Will I be working on Windows Azure?  Likely, not in my day job.  There might be some good fits for the cloud for the company, but I’m not aware of any major projects on the platform yet.  But, prior to going to work for the cloud computing services company I was mostly investing my own time and effort into Windows Azure anyway.  I have a few side projects in mind that will keep me up to date with Windows Azure beyond helping keep the Windows Azure Boot Camp program running.

So, time for yet another chapter in my career.  As many people have said, “change is coming”.  Strangely enough, change is the one constant in our field.  I’m glad to have had the opportunity to work with some great people over the last few months.  I’m glad I realized what was important to my life and I’m glad to have found the courage to chase it.

Windows Azure Office Hours

Thursday, November 10 2011         No Comments

Mike Benkovich (http://www.benkotips.com/ | @mbenko) hold an online event each week to talk about Windows Azure.  This week I’ll be joining him to talk about the Windows Azure Boot Camp program and more.  Come join us!  It will be tomorrow (Friday) at 2:00 PM Eastern.

Register to attend!

Seattle Interactive Conference has Cloud Track on Nov 2nd

Saturday, October 15 2011         No Comments

If you are out in the Northwest region of the United States in the beginning of November you may want to check out the Seattle Interactive Conference.  The conference is on November 2nd and 3rd.  Note that on November 2nd they plan on having a Cloud Experience Track.  The track is all about using the cloud as a back end for mobile platforms and other applications.  Windows Azure will be covered, but also it looks like they’ll have sessions for how to get some cloud love for your Android and iOS devices as well as Windows Phone 7.

You can find out more information on the Windows Azure Blog.

See the list of speakers.

and get registered ($350).

New Windows Azure SDK 1.5 Announced

Wednesday, September 14 2011         No Comments

Today at the BUILD conference they announced a lot new things, but for Windows Azure developers you’ll want to check out the announcements on the Windows Azure Team Blog.

A couple of big things to take note of in my opinion are:

  1. Better simulation of the cloud environment in the emulators.  It has been re-architected and updated.
  2. Release of the SDK 1.5 for Windows Azure AppFabric which includes a slew of updated features for the Service Bus that have been in the labs for a while.  Things like the distributed eventing and intra-app messaging.
  3. The management API got several new enhancements including rollback of in-progress updates and deployments.
  4. Geo-replication is now enabled for BLOB and Table storage!

There a lot more involved as well.  I’ll hopefully be getting to some blog posts around the new features soon.

#NotAtBldWin?

Tuesday, September 13 2011         No Comments

If you one of the MANY Windows Azure developers who weren’t able to make it to the Build Windows conference out in California this week then don’t worry too much.  Sure, you won’t get that spiffy new Samsung slate PC running Windows 8 Developer Preview, but you can get the same session information on Windows Azure. 

The focus of the BUILD conference is not the cloud, but they do have just under two dozen sessions dealing with Windows Azure.  Check out the Azure session online (they will be available online after they are recorded live):

Azure Sessions Page 1

Azure Sessions Page 2

Brian H. Prince will even be out giving an intro level Windows Azure talk called “Getting Started with Windows Azure” on Thursday.  If you aren’t familiar with Windows Azure then take an hour and watch his presentation after it’s available online.  Brian’s a great speaker and will give you the high level overview of what Windows Azure is and what its moving parts are.

Windows Azure Queue Tidbit

Tuesday, August 23 2011         No Comments

At a CINNUG meeting quite a while ago I was talking about the Windows Azure Storage subsystems: Queues, BLOBs and Tables.  While I was talking about Queues a question came up about using the Clear method on the CloudQueue object.  The MSDN Docs state: “The Clear method clears all messages from the queue”.   The question was, Does this also delete messages that are currently invisible (meaning a process has them taken them off the queue using GetMessage or GetMessages but has not deleted them yet)?  At the time I didn’t know the answer and said I would find out.  I even wrote a note to figure it out… which somehow ended up in the front of my notebook and completely forgotten. 

While I was sitting down at my laptop tonight this note slipped out of my notebook and reminded me that I still owe an answer to this.  I loaded up LINQPad and quickly set up some code to test this.  I created two queries in LINQPad.  One connected to a storage account, created a queue if it didn’t exist and added a message to the queue.  It also pulled the message from the queue with a timeout of about a minute then put the Thread to sleep for about a minute and a half.

Query One:

StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey(
	"somestorageAccountName",
	@"SomeStorageAccountKey"	);
CloudStorageAccount account = new CloudStorageAccount(credentials, true);
CloudQueueClient qClient = account.CreateCloudQueueClient();

CloudQueue q = qClient.GetQueueReference("sample");
q.CreateIfNotExist();

CloudQueueMessage msg = new CloudQueueMessage("Hello world");

q.AddMessage(msg);

CloudQueueMessage poppedMessage = q.GetMessage(TimeSpan.FromMinutes(1));

Thread.Sleep(TimeSpan.FromMinutes(1.5));

q.DeleteMessage(poppedMessage);

 

The second query connected to the same queue in the storage account and called Clear. 

Query Two:

//Same as above up to the creation of the queue reference.
CloudQueue q = qClient.GetQueueReference("sample");
q.CreateIfNotExist();

q.Clear();

 

I tested by executing the first query, which added a message and then pulled the message for processing, then immediately ran the second query.  At the end of the thread sleep in the first query the code attempted to delete the queue message which gave an error saying the queue message does not exist.

So yes, calling Clear does destroy ALL messages, even those hidden on the queue.  This does make sense as you are wanting to clear out the queue, but be aware that if you have code that has pulled a message for processing when Clear is called they will receive a StorageClientException (or a 404) when they go to delete that message from the queue.

The MSDN docs do mention that calling Clear on a queue that has a LOT of messages may timeout, in which case the client should retry to continue deleting the messages. 

On a side note, I was using http://myazurestorage.com to peek at the queue and contents as I was running this test and noticed that the ApproximateMessageCount property was returning 1 even after the message was grabbed off the queue, so it does take hidden messages into account.  Of course, as soon as I ran the second query this dropped to 0.   

Bytes by MSDN Interview

Monday, August 15 2011         No Comments

A while back I did an interview with Dave Nielsen (from CloudCamp).  This has been up on YouTube for a while, but has recently been posted to the Bytes by MSDN series.  You can catch the interview on the Bytes by MSDN site.

The abstract for the interview is:

“Join this cloud discussion with Michael Wood, from Strategic Data Systems, and Dave Nielsen, Co-founder of CloudCamp. At Strategic Data Systems, they work on various projects including proof of concepts. As projects get backlogged, proof of concepts and small projects lose out. Dave and Mike discuss how Cloud Computing can alleviate the backlog and lower the barrier to innovation. Tune in to the end, to receive instructions on how to access your free 30-day pass to a Windows Azure account.”

This interview was taken back at the beginning of the year when I still worked at SDS.