Partager via


Auto-scaling in Azure.

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

  • Anonymous
    December 27, 2010
    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.