SebastianStehle
SebastianStehle

Reputation: 2459

How to scale a azure cloud service to reduce billing

we have a batch operation, progressing some data. The operation takes about 2 hours and needs a lot of RAM at the moment. Therefore we have a cloud service with 56GB of RAM in Microsoft azure. This operation should run each night, so the rest of the 22 hours we pay the service for doing nothing.

I am looking for a simple solution to automatically scale the cloud service to reduce billing. Unfortunately you cannot set the minimum instance size to be zero, when you use the autoscaling feature of microsoft azure.

How do you solve the problem? Are there any tools available?

Upvotes: 0

Views: 369

Answers (2)

David Makogon
David Makogon

Reputation: 71031

Assuming you're staying with Cloud Services: While you cannot scale down to zero instances of a web or worker role, you can change the role size (which can be done programmatically, via PowerShell, via CLI, or via portal), and this can be done programmatically. This would give you the option of scaling to the larger size, running your batch processing, and then scaling down to an "idling" size (you could technically scale all the way down to an A0) and, assuming you had scaled to multiple role instances, you could scale in to one instance as well. While this isn't a zero-cost solution, it's very inexpensive ($0.02/hour list price).

Upvotes: 0

Gaurav Mantri
Gaurav Mantri

Reputation: 136126

You're correct that as of today, Azure Cloud Services can't be scaled down to zero instances. At the very least, one instance is required. One way to solve this problem is to create/delete deployments programmatically using Azure Service Management API. So what you could do is create a job which will:

  1. At certain time of day, deploy this package and create the cloud service using Service Management API. Since it takes some time for the deployment to be up and running, you would probably want to do this at least 30 minutes before the time your operation should start.
  2. Once the operation completes, either it can destruct itself by calling the Service Management API again or you could have another job which is scheduled to run at least 30 minutes after your job completion time.

To schedule this job, you have many options available in Azure:

  1. You could use Azure Automation.
  2. You could create a WebJob and run it on a fixed schedule.
  3. You could use Azure Scheduler Service.
  4. You could write your own code to schedule this job and host it in another Worker Role.

Upvotes: 1

Related Questions