Deleting Instances on Azure Cloud Services

One small new feature added to the Windows Azure Management API recently is the ability to ‘delete’ individual instances in a Cloud Service.

More information here: http://msdn.microsoft.com/en-us/library/windowsazure/dn469418.aspx

What’s changed?

Previously you were able to reduce the instance count of a Cloud Service deployment, which would always delete the last instance in the Role. This new feature allows you to choose which instances you want to remove.

Why is this useful?

In most scenarios it isn’t. However there are a few cases where this could be useful:

Batch Processing

If you have a large computational job you want to run in the cloud, it makes sense to chop this into a series of small jobs and distribute these amongst a number of instances, perhaps using a queue to coordinate this. But what happens when the queue is drained? Some workers are likely to finish before others, and you can’t predict which is going to complete first (drawing from the queue randomises the order).

Now you can write some logic so that instances delete themselves when the queue is empty. Because billing is now down to the nearest minute, it makes sense to turn machines off when you get the opportunity.

Machine Quality

Perhaps you request 100 machines and one turns out to be a duffer. By this I mean you don’t get the perf you expect. I’m not aware of this being  much of a problem in Azure, however other clouds which contain a mix of old/new hardware certainly do suffer from this.

Running a quick benchmark on boot would reveal whether the machine is good enough, if not, delete and ask for another one – hoping you don’t get the same one back again!

Multi-tenancy

Some (clever) people are taking old single-tenant software and multi-tenanting on Azure. They’re dynamically provisioning customers on Web/Worker Roles, and then programming a reverse proxy like ARR or Nginx to route incoming traffic for the right instance for that customer. This means that load is not always evenly distributed across instances.

When it comes to scaling down, it’s often easier to remove one of the instances with only a few customers provisioned on it, as this would mean transitioning fewer installations.

Update 1

Gaurav Mantri has posted an excellent code sample on his blog:

http://gauravmantri.com/2013/10/16/a-new-version-of-windows-azure-service-management-api-is-available-with-delete-specific-role-instances-and-more-goodies/

Update 2

I have since created a ‘self destruct’ project on GitHub, making it really easy for an instance to delete itself.

https://github.com/richorama/Two10.Azure.SelfDestruct

Advertisements