32
Cloud Design Patterns – part 2 Masashi Narumoto AzureCAT patterns & practices Microsoft

Cloud Design Pattern part2

Embed Size (px)

Citation preview

Page 1: Cloud Design Pattern part2

Cloud Design Patterns – part 2Masashi NarumotoAzureCAT patterns & practicesMicrosoft

Page 2: Cloud Design Pattern part2

RetryCircuit BreakerQueue based load levelingThrottlingLeader ElectionValet Key

Agenda

Page 3: Cloud Design Pattern part2

Retry problem – access to resource fails

Web siteUser Remote resource

Error

Page 4: Cloud Design Pattern part2

Retry solution

Web siteUser Remote resource

HTTP 500

HTTP 500

HTTP 200

When to retry?interval/count?

Page 5: Cloud Design Pattern part2

Service Retry capabilities Policy configuration Scope Telemetry features

AzureStorage Native in client Programmatic Client and individual operations TraceSource

SQL Database with Entity Framework

Native in client Programmatic Global per AppDomain None

SQL Database with ADO.NET

Topaz* Declarative and programmatic

Single statements or blocks of code Custom

Service Bus Native in client ProgrammaticNamespace Manager, Messaging Factory, and Client

ETW

Cache Native in client Programmatic Client TextWriterDocumentDB Native in service Non-configurable Global TraceSource

Search Topaz* (with custom detection strategy)

Declarative and programmatic Blocks of code Custom

Active Directory Topaz* (with custom detection strategy)

Declarative and programmatic Blocks of code Custom

Retry solution

Page 6: Cloud Design Pattern part2

Only retry transient errorsRetry strategy per contextAvoid cascading retryUse built-in retry logicTest/Log retry operations

Retry design considerations

https://github.com/mspnp/azure-guidance/blob/master/Retry-Service-Specific.md

Page 7: Cloud Design Pattern part2

Circuit Breaker problem - remote service causes cascading failure

Web siteUser Remote service

error

Retry consume memory, thread, network connection etc.

Page 8: Cloud Design Pattern part2

Circuit Breaker solution

Page 9: Cloud Design Pattern part2

Exception handling in Open stateTransition to Half-Open stateManual overwriteUnderstand the protected resourcesAccelerated Circuit BreakingNG for local resources

Circuit Breaker design considerations

Page 10: Cloud Design Pattern part2

Queue Based Load Leveling problem Surge in requests exhaust resources

UserDatabase

XWeb Site

Page 11: Cloud Design Pattern part2

Queue Based Load Leveling solution

Database

Use queue as a buffer

Rate of requests Rate of processing

Web site

Page 12: Cloud Design Pattern part2

Reduce the rate that resource can handleIdentify # of queue/worker by testsUse reply queue when neededLatency will increase

Queue Based Load Leveling considerations

Page 13: Cloud Design Pattern part2

Throttling problem - surge in workload

Web siteUser

Storage

Multi-tenant

Page 14: Cloud Design Pattern part2

Throttling solution

Page 15: Cloud Design Pattern part2

Design the strategy early onPerform quicklyCan be used together with auto-scalingAggressive auto-scaling if demand grow very quickly

Throttling design considerations

Page 16: Cloud Design Pattern part2

Leader Election problem – control distribution

Storage Split/Shuffle

Mapper/Reducer

Page 17: Cloud Design Pattern part2

Leader Election solution

1. Try to acquire blob lease2. First one that acquires it is the leader3. Leader dispatches task to other instances4. Leader renews the lease

Page 18: Cloud Design Pattern part2

Make the election process resilientReplace leader when it goes downDistributed mutex could be SPOFConsider the leader may be removed by auto-scaling

Leader Election design considerations

Page 19: Cloud Design Pattern part2

Valet Key problem – protect storage

ApplicationUser StorageMalicious user

Page 20: Cloud Design Pattern part2

Valet Key Solution

Page 21: Cloud Design Pattern part2

Manage the key validity and controlBe aware you lose some controlValidate/Sanitize uploaded dataEnsure start time is earlier than currentGood for offloading from compute resource and reducing costs

Valet Key design considerations

Page 22: Cloud Design Pattern part2

✔ ✔

Page 23: Cloud Design Pattern part2

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

Page 24: Cloud Design Pattern part2

Index Table problem Lack of 2ndary index

Query:Customers in Redmond?Customers(name=‘smith’)?

Page 25: Cloud Design Pattern part2

Index Table solution

Create another table with ‘town’ as index

Pros:- Query is fast since the new table has all dataCons:- Table size becomes large- Data consistency issue

Page 26: Cloud Design Pattern part2

Index Table solution

Pros:- Table size is small- Less consistency issuesCons:- 2 step lookup makes query slow

Create index only table

Page 27: Cloud Design Pattern part2

Index Table solution

Partially normalized table

Pros:- Query is fast- Table size is smallCons:- Depends heavily on Data access pattern

Page 28: Cloud Design Pattern part2

Index Table solution

Combined key ‘Town’_’Name’

Page 29: Cloud Design Pattern part2

Maintaining tables brings overhead Total table size will increase Data consistency issuesIndex skew problem

Index Table considerations

Page 30: Cloud Design Pattern part2

Static Content Hosting problem – storing static content 

cspkg

HTMLJava Script, CSS, Images

Request

DevOpsUserWeb site

Page 31: Cloud Design Pattern part2

Static Content Hosting solution 

cspkgHTML w/ link to content

request

DevOpsUser

cspkgJava Script, CSS, ImagesStatic content

Web site

CDN/Blob

Page 32: Cloud Design Pattern part2

Deployment and version controlVersion checkCache control/compressionStatic web siteEnable CORS for script

Static Content Hosting design considerations