Strive for excellence through continuous improvements

Windows Azure - Cloud computing blog

Auto-scaling in Azure.

Auto-scaling in Azure.

Rate This
  • Comments 2

A really complete example has been published on Windows Azure Dynamic Scaling Sample talking about this topic.

If you are still interested on knowing how this requirement can be “manually” implemented,continue reading this post,otherwise I would recommend you to visit the Windows Azure Dynamic Scaling Sample

 

Combining the strengthens of the Windows Azure Diagnostics API and the Service Management API makes really easy to implement your own logic for auto-scaling your Azure Services.

In this post I will show you how I have implemented a PoC for auto-scaling an Azure Solution and the different options that you have for implementing a similar solution.

1. Solution architecture

The solution components are :

  • The Financial service : A WCF service hosted in Azure Web roles.It has two web roles distributed across two upgrade domains for assuring availability.
  • The controller Service :  A Controller service hosted in a Azure Worker role.
    • Using the Diagnostics API, it remotely requests the Financial Service to transfer its performance counters to a Azure Table Storage.
    • If it detects a high CPU usage (90% Usage for 3 minutes) Using the Service Management API it will automatically scale the Financial Service.

The following diagram illustrates the solution architecture :

AutoScaling_2

It would also have been possible to host the Controller Service in a traditional on premise service.The following diagram illustrates that option:

AutoScaling_1

2.  Using the Diagnostics API for reading performance counters

With the Diagnostics API you can :

  • Dynamically modify the set of counters and traces that your Azure Service will generate.You can modify this configuration from inside your Azure service or remotely (from another Azure Service or from an on premise application).For that purpose you will have to use the class DeploymentDiagnosticManager.

 

  • Request to transfer diagnostic data to Azure Storage,from inside the role that you want to instrument or also remotely (for instance another role or a traditional in-premise service).

The following table outlines the traces and counters that can be activeted and where are stored .

 

Diagnostic Data Type

Default Configuration

Stored in WA Storage as

Windows Azure Logs

Enabled and generating logs locally

Contains logs from the diagnostic infrastructure, which help the user troubleshoot issues with the diagnostic monitoring system itself.

Table

WADInfrastructureLogsTable

Diagnostic Monitor Logs

Enabled and generating logs locally

Contains the logs generated by your service using standard .NET Tracing APIs.

Table

WADLogsTable

Performance Counters

Not Enabled

Table

WADPerformanceCountersTable

Windows Event Logs

Not Enabled

Table

WADLogsTable

Application Crash Dumps

Not Enabled

Blob

wad-crash-dumps

IIS Logs

Enabled and generating logs locally

Blob

wad-crash-dumps

Failed Request Logs

Enabled

Blob

wad-iis-failedreqlogfiles

Arbitrary Logs

Not Enabled

Blob

For detailed information about implementing diagnostics in Azure go to the link Implementing Windows Azure Diagnostics

3. Scaling an Azure Service

For scaling an Azure service, you must consume the Service Management API.

Before being able to consume the API, you should generate a self-signed certificate for authenticating the service requests.You can show how this can be achieved in the following link Authenticating Service Management Requests.

After that, you have the following options for consuming the service management API and scaling the service:

When updating the service configuration,the key it’s to modify the Instances count param of the service configuration.For instance, this XML represents Financial Service configuration contained in the .csfg file

<Role name="GRC.BasicFinancialService">
    <Instances count="1" />
    <ConfigurationSettings>
      <Setting name="DiagnosticsConnectionString" value="UseDevelopmentStorage=true" />
    </ConfigurationSettings>
  </Role>

If you want to scale the service using a the power shell cmdlets here you have an example :

string scaleScript="Add-PSSnapin AzureManagementToolsSnapIn "+

"Get-HostedService $serviceName -Certificate $cert -SubscriptionId $subId | "+

"Get-Deployment -Slot Production | " +

"Set-DeploymentConfiguration {$_.RolesConfiguration[$roleName].InstancesCount+=1}" ;

 

I hope that this post has helped you to see the wide set of options that you have for implementing diagnostics in your Azure Service.

I will upload the PoC I have used as soon as it is fully tested.

Comments
  • The example is really excellent and very useful.If I want to implement same application on Development fabric will it support after doing some code changes related to development fabric.

  • Microsoft shipped the Autoscaling Application Block (Wasabi) to provide dynamic scaling of Azure apps -  http://aka.ms/wasabi. Some of the supported scenarios:

    1.Autoscaling both web and worker roles in Windows Azure by dynamically changing instance counts or performing application throttling.

    2.Autoscaling Windows Azure roles based on timetables.

    3.Autoscaling Windows Azure roles based on metrics collected from the application and/or Windows Azure but constrained by upper and lower bounds on the instance count per role.

    4.Preventing fast oscillations in the number of role instances with the stabilizer. The stabilizer can also help to optimize costs by limiting scaling up operations to the beginning of the hour and scaling down operations to the end of the hour.

    5.Monitoring and logging autoscaling activity.

    6.Sending notifications to preview any scaling operations before they take place.

    7.Encrypting the rules and other configuration in Windows Azure blob storage or in local file storage.

    8.Managing the autoscaler configuration by using Windows PowerShell.

    A comprehensie sample application (Tailspin Surveys) showcasing all these features is provided. Also, check out the Developer's Guide (entlib.codeplex.com/.../308781) and the Channel9 video walkthrough (channel9.msdn.com/.../Episode-74-Autoscaling-and-Endpoint-Protection-in-Windows-Azure).

    The block is available as standalone download of binaries, source or via NuGet.

Page 1 of 1 (2 items)
Leave a Comment
  • Please add 5 and 6 and type the answer here:
  • Post