+ All Categories
Home > Documents > Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant,...

Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant,...

Date post: 11-Jan-2016
Category:
Upload: hector-smith
View: 212 times
Download: 1 times
Share this document with a friend
38
Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a
Transcript
Page 1: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Building Robust Windows Azure Applications with P&P Guidance@MaheshKrishnanPrincipal Consultant, Readify

AZR323a

Page 2: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

AgendaWhat’s covered

Auto ScalingScaling conceptsAddressing scaling using Windows Azure Scaling Application Block (WASABi)

Transient errorsThe BasicsAddressing these errors using Transient Fault Handling Application Block (TOPAZ)

Page 3: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Cloud benefits – a recap

Zero or low upfront costLower on-going costSeemingly infinite resourcesElasticity on demand

Page 4: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Scaling - Basics

Helps balance running cost with load and performanceVertical Scaling

Increase or decrease VM size(Scale up/down)

Horizontal ScalingIncrease or decrease number of instances(Scale out/in)

Page 5: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Manual scaling

Manual scaling useful for once-off scaling. Not good under other scenariosManual intervention = mistakes

Page 6: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Two types of scaling

ProactiveReactive

Page 7: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

My auto scaling wish list

Should be built into AzureScale out/in based on time tableScale out/in based on perf. counters, queue size, etcWork to my SLAsDon’t break the bank (work within budget)Configuration not done in code

Page 8: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Wish list (contd)

On heavy load, start cutting back on high CPU tasks/featuresMake optimum use of my billing cyclesPreferably host in Azure on a Worker roleCover multiple sites with one App

Page 9: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Options for Auto scaling

Use a SaaS provider Azure Watch

Build your ownLeverage on p&p Guidance and existing framework

Windows Azure Scaling Application Block (WASABi)

Page 10: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

WASABi Features

Supports auto-scaling of instancesThrottling Scaling options:

Can be reactive or proactiveHosting:

In Azure: worker roleOn premise: Windows service, Stand alone app

Page 11: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Installation

Use NuGetInstall-Package EnterpriseLibrary.WindowsAzure.Autoscaling

Install the Enterprise Library Configuration Editor

Page 12: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Configuration

Some additions to the App/Web.config fileTwo additional configuration files:

One for rules, such as Rules.xmlOne fore Service info, such as Services.xml

Rules and Service info configuration can be stored in Blobs

Page 13: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

public class WorkerRole : RoleEntryPoint{ private Autoscaler _autoscaler; ... public override bool OnStart() { _autoscaler = EnterpriseLibraryContainer.Current. GetInstance<Autoscaler>(); _autoscaler.Start(); ... } public override void OnStop() { _autoscaler.Stop(); ... }}

Changes in code

Page 14: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Proactive scaling

Constraint RulesUsing time tablesBudget limitsRanking for overlapping rules

Overrides reactive rules

Page 15: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Proactive or constraint rules

<rules xmlns="http://schemas.microsoft.com/practices/2011/entlib/autoscaling/rules"> <constraintRules> <rule name="Default" rank="1"> <actions> <range min="2" max="6" target="SM.Website"/> </actions> </rule> <rule name="Peak" rank="10"> <timetable startTime="08:00:00" duration="08:00:00" utcOffset="+10:00" > <!--<weekly days="Monday Tuesday Wednesday Thursday Friday"/>--> <daily/> </timetable> <actions> ... </actions> </rule> </constraintRules></rules>

Page 16: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Reactive scaling

Use conditions to change instance count or perform specific actionMonitor:

Performance counters thresholdsQueue lengthsCustom business metrics thresholdsEven instance counts

Page 17: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Reactive rules <reactiveRules> <rule name="ScaleUpOnHighUtilization" rank="15" > <when> <greater operand="CPU" than ="60"/> </when> <actions> <scale target="SM.Website" by="1"/> </actions> </rule> <rule name="ScaleDownOnLowUtilization" rank="20" > <when> <less operand="CPU" than ="30"/> </when> <actions> <scale target="SM.Website" by="-1"/> </actions> </rule> </reactiveRules>

Page 18: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Operand

Can be one of the following:performanceCounterqueueLengthinstanceCount

<operands> <performanceCounter alias="CPU" performanceCounterName="\Processor(_Total)\% Processor Time" source="SM.Website" timespan="00:05:00" aggregate="Average"/> </operands>

Page 19: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

What to monitor?

\Processor(_Total)\% Processor Time \Memory\Available Bytes \.NET CLR Memory(_Global_)\% Time in GC

Page 20: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Throttling

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" > <when> <greater operand="CPU" than ="60"/> </when> <actions> <changeSetting settingName="Throttle" target="SM.Website" value="true" /> </actions> </rule>

Page 21: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Stabilization

The Oscillations problemCool down settings – for both Scale up and downSettings to scale during first few minutes of hour or scale down during last few minutes of an hour

<stablizer> <role roleAlias=“SM.Website” scaleDownCooldown=“00:10:00” scaleUpCooldown=“00:10:00” scaleDownOnlyinLastMinutesOfHour=“10”

scaleUpOnlyInFirstMinutesOfHour=“30”></stablizer>

Page 22: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

demo

NameTitleGroup

WASABi in action

Page 23: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Transient ErrorsHandling them using TOPAZ

Page 24: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Typical cloud implementation– a recap

Shared infrastructure Virtualized environmentMulti-tenanted

Page 25: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Transient Errors

Occurs in:Data Management - SQL Database, TablesMessaging – Queues, Service BusCaching

Examples of errors:SQL Database ThrottlingDropped/Stale connectionsInfrastructure issuesService unavailability

Page 26: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Some Transient Error codes

Page 27: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Transient Error Handling Application Block

Will detect known Transient errorsAllows you to specify Retry strategiesContains classes/methods to perform retry logic easily

Page 28: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Retry policies

Fixed IntervalExample – Retry 4 times at 1 second interval

Incremental IntervalExample – Retry 4 times at 1, 2, 3, and 4 second intervals

Exponential Back offExample – Retry 4 times at 2, 4, 8 and 16 seconds intervals

Page 29: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Installation

Use NuGetInstall-Package EnterpriseLibrary.WindowsAzure.TransientFaultHandling

Install the Enterprise Library Configuration Editor

Page 30: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Configuration

Allows you to configure Retry strategies

Page 31: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Using the App block with SQL Database

Contains ReliableSqLConnection classSQLConnectionExtension contains extension methods for SqlConnection

Ex - OpenWithRetrySQLCommandExtension contains extension methods for IDbConnection

Ex – ExecuteCommand

Page 32: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

ReliableSqlConnection usage

//Use retry aware connectionusing (var conn = new ReliableSqlConnection (connString, retryPolicy)){ conn.Open(); var cmd = conn.CreateCommand(); cmd.CommandText = sqlStmt;

//retry aware ExecuteCommand int count = cmd.ExecuteScalar();

}

Page 33: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Other scenarios (LinqToSql, EF)

sqlRetryPolicy.ExecuteAction(() =>{ // Invoke a LinqToSQL query.});

return sqlRetryPolicy.ExecuteAction<IEnumerable<string>>(() =>{ // Invoke a EF LINQ query return result;});

Page 34: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

Gotchas

Remember that queries are actually executed when they are enumeratedSimilarly, Updates/Delete/Inserts are called when SaveChanges are calledAvoid Lazy loading

Page 35: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

demo

NameTitleGroup

TOPAZ in action

Page 36: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

SummaryWASABi

Auto scaling can be done reactively or proactivelyCreate a separate Worker role (or use existing one)Install the NuGet packageSpecify constraint and reactive rules in configuration filesInitialise the App Block

Page 37: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

SummaryTOPAZ

Helps handle transient errors by retryingInstall NuGet packageSpecify retry strategy in configuration filesMost common usage scenario: SQL Database

Use ReliableSqlConnection instead of SQLConnectionUse extension methods on IDbCommand when executing queries

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

Page 38: Building Robust Windows Azure Applications with P&P Guidance @MaheshKrishnan Principal Consultant, Readify AZR323a.

© 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.


Recommended