Building robust windows azure applications with p p guidance
1 / 38

Building Robust Windows Azure Applications with P&P Guidance - PowerPoint PPT Presentation

  • Uploaded on

AZR323a. Building Robust Windows Azure Applications with P&P Guidance. @ MaheshKrishnan Principal Consultant, Readify. Agenda What’s covered. Auto Scaling Scaling concepts Addressing scaling using Windows Azure Scaling Application Block ( WASABi ) Transient errors The Basics

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Building Robust Windows Azure Applications with P&P Guidance' - meli

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Building robust windows azure applications with p p guidance


Building Robust Windows Azure Applications with P&P Guidance


Principal Consultant, Readify

Agenda what s covered
AgendaWhat’s covered

  • Auto Scaling

    • Scaling concepts

    • Addressing scaling using Windows Azure Scaling Application Block (WASABi)

  • Transient errors

    • The Basics

    • Addressing these errors using Transient Fault Handling Application Block (TOPAZ)

Cloud benefits a recap
Cloud benefits – a recap

  • Zero or low upfront cost

  • Lower on-going cost

  • Seemingly infinite resources

  • Elasticity on demand

Scaling basics
Scaling - Basics

  • Helps balance running cost with load and performance

  • Vertical Scaling

    • Increase or decrease VM size

    • (Scale up/down)

  • Horizontal Scaling

    • Increase or decrease number of instances

    • (Scale out/in)

Manual scaling
Manual scaling

  • Manual scaling useful for once-off scaling. Not good under other scenarios

  • Manual intervention = mistakes

Two types of scaling
Two types of scaling

  • Proactive

  • Reactive

My auto scaling wish list
My auto scaling wish list

  • Should be built into Azure

  • Scale out/in based on time table

  • Scale out/in based on perf. counters, queue size, etc

  • Work to my SLAs

  • Don’t break the bank (work within budget)

  • Configuration not done in code

Wish list contd
Wish list (contd)

  • On heavy load, start cutting back on high CPU tasks/features

  • Make optimum use of my billing cycles

  • Preferably host in Azure on a Worker role

  • Cover multiple sites with one App

Options for auto scaling
Options for Auto scaling

  • Use a SaaS provider

    • Azure Watch

  • Build your own

  • Leverage on p&p Guidance and existing framework

    • Windows Azure Scaling Application Block (WASABi)

Wasabi features
WASABi Features

  • Supports auto-scaling of instances

  • Throttling

  • Scaling options:

    • Can be reactive or proactive

  • Hosting:

    • In Azure: worker role

    • On premise: Windows service, Stand alone app


  • Use NuGet

    • Install-Package EnterpriseLibrary.WindowsAzure.Autoscaling

  • Install the Enterprise Library Configuration Editor


  • Some additions to the App/Web.config file

  • Two additional configuration files:

    • One for rules, such as Rules.xml

    • One fore Service info, such as Services.xml

  • Rules and Service info configuration can be stored in Blobs

Changes in code

public class WorkerRole : RoleEntryPoint


private Autoscaler _autoscaler;


public override boolOnStart()


_autoscaler = EnterpriseLibraryContainer.Current.





public override void OnStop()






Proactive scaling
Proactive scaling

  • Constraint Rules

    • Using time tables

    • Budget limits

    • Ranking for overlapping rules

  • Overrides reactive rules

Proactive or constraint rules
Proactive or constraint rules

<rules xmlns=



<rule name="Default" rank="1">


<range min="2" max="6" target="SM.Website"/>



<rule name="Peak" rank="10">

<timetable startTime="08:00:00" duration="08:00:00" utcOffset="+10:00" >

<!--<weekly days="Monday Tuesday Wednesday Thursday Friday"/>-->



<actions> ... </actions>




Reactive scaling
Reactive scaling

  • Use conditions to change instance count or perform specific action

  • Monitor:

    • Performance counters thresholds

    • Queue lengths

    • Custom business metrics thresholds

    • Even instance counts

Reactive rules
Reactive rules


<rule name="ScaleUpOnHighUtilization" rank="15" >


<greater operand="CPU" than ="60"/>



<scale target="SM.Website" by="1"/>



<rule name="ScaleDownOnLowUtilization" rank="20" >


<less operand="CPU" than ="30"/>



<scale target="SM.Website" by="-1"/>





  • Can be one of the following:

    • performanceCounter

    • queueLength

    • instanceCount


<performanceCounter alias="CPU"

performanceCounterName="\Processor(_Total)\% Processor Time"


timespan="00:05:00" aggregate="Average"/>


What to monitor
What to monitor?

  • \Processor(_Total)\% Processor Time

  • \Memory\Available Bytes

  • \.NET CLR Memory(_Global_)\% Time in GC


  • Use config settings to cut back on features (like some CPU intensive features, or only allowing paid users)

  • Throttling is faster than generating new instances

<rule name="ThrottlingRule" rank="50" >


<greater operand="CPU" than ="60"/>



<changeSettingsettingName="Throttle" target="SM.Website" value="true" />




  • The Oscillations problem

  • Cool down settings – for both Scale up and down

  • Settings to scale during first few minutes of hour or scale down during last few minutes of an hour


<role roleAlias=“SM.Website” scaleDownCooldown=“00:10:00”





Wasabi in action


WASABi in action




Handling them using topaz

Transient Errors

Handling them using TOPAZ

Typical cloud implementation a recap
Typical cloud implementation– a recap

  • Shared infrastructure

  • Virtualized environment

  • Multi-tenanted

Transient errors
Transient Errors

  • Occurs in:

    • Data Management - SQL Database, Tables

    • Messaging – Queues, Service Bus

    • Caching

  • Examples of errors:

    • SQL Database Throttling

    • Dropped/Stale connections

    • Infrastructure issues

    • Service unavailability

Transient error handling application block
Transient Error Handling Application Block

  • Will detect known Transient errors

  • Allows you to specify Retry strategies

  • Contains classes/methods to perform retry logic easily

Retry policies
Retry policies

  • Fixed Interval

    • Example – Retry 4 times at 1 second interval

  • Incremental Interval

    • Example – Retry 4 times at 1, 2, 3, and 4 second intervals

  • Exponential Back off

    • Example – Retry 4 times at 2, 4, 8 and 16 seconds intervals


  • Use NuGet

    • Install-Package EnterpriseLibrary.WindowsAzure.TransientFaultHandling

  • Install the Enterprise Library Configuration Editor


  • Allows you to configure Retry strategies

Using the app block with sql database
Using the App block with SQL Database

  • Contains ReliableSqLConnection class

  • SQLConnectionExtension contains extension methods for SqlConnection

    • Ex - OpenWithRetry

  • SQLCommandExtensioncontains extension methods for IDbConnection

    • Ex – ExecuteCommand

Reliablesqlconnection usage
ReliableSqlConnection usage

//Use retry aware connection

using (var conn = new ReliableSqlConnection

(connString, retryPolicy))



varcmd= conn.CreateCommand();

cmd.CommandText= sqlStmt;

//retry aware ExecuteCommand

int count = cmd.ExecuteScalar();


Other scenarios linqtosql ef
Other scenarios (LinqToSql, EF)

sqlRetryPolicy.ExecuteAction(() =>


// Invoke a LinqToSQLquery.


return sqlRetryPolicy.ExecuteAction<IEnumerable<string>>(

() =>


// Invoke a EF LINQ query

return result;



  • Remember that queries are actually executed when they are enumerated

  • Similarly, Updates/Delete/Inserts are called when SaveChanges are called

  • Avoid Lazy loading

Topaz in action


TOPAZ in action




Summary wasabi

  • Auto scaling can be done reactively or proactively

  • Create a separate Worker role (or use existing one)

  • Install the NuGet package

  • Specify constraint and reactive rules in configuration files

  • Initialise the App Block

Summary topaz

  • Helps handle transient errors by retrying

  • Install NuGet package

  • Specify retry strategy in configuration files

  • Most common usage scenario: SQL Database

    • Use ReliableSqlConnection instead of SQLConnection

    • Use extension methods on IDbCommand when executing queries

  • Use ExecuteAction method on RetryPolicy for everything else (including ORMs)

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.