building scalable, global, and highly available web apps name title microsoft corporation

34
Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Upload: bryan-lawrence

Post on 16-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Building Scalable, Global, and Highly Available Web AppsNameTitleMicrosoft Corporation

Page 2: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Agenda

Design for High Availability

Design for High Scalability

Design for Performance

Page 3: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Assumptions

You know the basicsWindows Azure Web/Worker RolesSQL DatabaseWindows Azure StorageAsynchronous ProgrammingWindows Azure diagnostics

You have deployed a service to Windows Azure

Everything can and will (eventually) break

Page 4: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Availability

Page 5: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Why do services fail?

Increased workload

FailureHardwareNetwork Platform ServiceTransient conditions

HumanUpgrades

Page 6: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

What do we mean by available?

Same functionality

Degraded functionality

Failsafe

Page 7: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Basics – what you get for free

ElasticityEasily deploy compute resources and scale up and down

Automated Service ManagementWindows Azure will (automatically) recover bad nodes

Fault DomainsWindows Azure deploys services across fault boundaries

Storage Resilience3 copies of storage maintained

Page 8: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Fault ToleranceWhen Windows Azure breaks, it fixes itself!Can your service?

Codifying OperationsUpgrade DomainsConfigure in ServiceDefinition.csdef<ServiceDefinition name="RedDir"xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" upgradeDomainCount="3">

Transient Datacenter ConditionsDo you have Retry Logic?

Page 9: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

What did you mean, retry logic?Transient conditions in the datacenter/network/serviceExample:SQL Azure Error 40501The service is currently busy. Retry the request after 10 seconds.

Transient Fault Handling Frameworkhttp://windowsazurecat.com/2011/02/transient-fault-handling-framework/

Retry against anything that might be external and have transient conditions*:SQL DatabaseWindows Azure StorageService Bus3rd Party Services

Page 10: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Retry

demo

Page 11: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Service Specific Implementations

Does your service fail without that platform service?

Can your service use the same platform services from another data center?

Can your service not use that platform service temporarily?

Page 12: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Site Failover

If a site specific dependency is out, fail over to another site

Easy: Use Traffic Manager

Hard: Code your own

Page 13: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Site Failover

demo

Page 14: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Upgrade Strategies: VIP Swap

Page 15: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Upgrade Strategies: Upgrade

WEB WORKER WEB WORKER

Page 16: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Upgrade StrategiesNew Service & Swap DNS

Page 17: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Scalability

Page 18: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

It is better to have 50 x 1GB database than 1 x 50GB database

What is wrong with this?

Scale me out too

Page 19: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Everything needs to scale

What about this?

Page 20: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Synchronous Design PatternEach thread dedicated to one outstanding requestBlock on each step of “the work” done for each request, then respond & repeat

This approach scales poorlyEach outstanding request is stored on a thread stackThreads block even when there is work to be doneAdding a thread enables only one additional concurrent request

Client Request #1Web App Front End

Client Response #1

Client Request #2

“The Work” #1

Response #1

Time passes…

Thread Thread

Waiting…blocks

Page 21: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Asynchronous Design PatternEach thread picks up work whenever it is readyA thread handling one request may handle another before the first one completes

Client Request #1Web App Front End

Client Response #1Client Request #2

“The Work” #1

Response #1Thread Thread

Client Response #2

“The Work” #2

Response #2

This approach scales wellClient requests tracked explicitly in app’s data structuresThreads never block while there is work to be doneEach thread can handle possibly many concurrent requests

But bookkeeping & synchronization can be difficult…

Page 22: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Performance

Page 23: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

What’s Windows Azure Cache?

• Use spare memory on your VMs as high-performance cache

• Distributed cache cluster co-located with existing roles, or use dedicated roles

• Named caches with high availability option and notifications

• Support Memcached protocol

Page 24: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Why Windows Azure Cache?

FasterNo external service calls (additional network hops)Co-located in roles

CheaperNo external service calls (additional cost)Use spare memory that you already paid for

More reliableYour service is running = cache is availableNo throttling as in cotenant environment

Page 25: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Cache

demo

Page 26: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Why Performance Matters

More responsive applicationsFaster page load times8 seconds vs. 3 seconds?

Higher interactivity – new type of applicationsBetter user experience – more $$$

Page 27: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Thinking Globally

Network latencyPut compute closer to user.Put data closer to user.

Global availabilityDatacenter outages.Synchronizing data.

Page 28: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Network Latency

Page 29: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Content Delivery Network (CDN)

High-bandwidth global blob content delivery24 locations globally (US, Europe, Asia, Australia and South America), and growingSame experience for users no matter how far they are from the geo-location where the storage account is hosted

Blob service URL vs CDN URL:Windows Azure Blob URL: http://images.blob.core.windows.net/Windows Azure CDN URL: http://<id>.vo.msecnd.net/ Custom Domain Name for CDN: http://cdn.contoso.com/

Page 30: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Windows Azure CDN

pic1.jpg

To Enable CDN:Register for CDN via Dev PortalSet container images to public

pic1.jpg

GEThttp://guid01.vo.msecnd.net/images/pic.1jpg

http://sally.blob.core.windows.net/images/pic1.jpg

http://sally.blob.core.windows.net/ http://guid01.vo.msecnd.net/

pic1.jpg

404

TTL Content Delivery Network

Windows Azure Blob Service

EdgeLocation

EdgeLocation

EdgeLocation

Page 31: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Windows Azure Traffic ManagerDirect users to the service in the closest region with the Windows Azure Traffic Manager

Policies Monitoring

foo.cloudapp.net

DNS response

1.2.3.4

Page 32: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Traffic Manager

demo

Page 33: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

Summary

Windows Azure gives you high availability capabilities for freeThink about scaling outHandle transient conditions

Design for scalabilityAsynchronous patternScale out

Design for maximum performance & reachCaching, CDN, Traffic Manager, etc.

Page 34: Building Scalable, Global, and Highly Available Web Apps Name Title Microsoft Corporation

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

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