building scalable web apps with windows azure l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Building scalable web apps with Windows Azure PowerPoint Presentation
Download Presentation
Building scalable web apps with Windows Azure

Loading in 2 Seconds...

play fullscreen
1 / 26

Building scalable web apps with Windows Azure - PowerPoint PPT Presentation


  • 496 Views
  • Uploaded on

SAC-870T. Building scalable web apps with Windows Azure. Matthew Kerner Principal Program Manager Microsoft Corporation. Agenda. WHO WILL BENEFIT FROM THIS TALK. TOPICS. WHAT YOU’LL LEAVE WITH. Windows Azure helps you build scalable web apps

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

PowerPoint Slideshow about 'Building scalable web apps with Windows Azure' - niveditha


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 scalable web apps with windows azure
SAC-870T

Building scalable web apps with Windows Azure

Matthew Kerner

Principal Program Manager

Microsoft Corporation

agenda
Agenda

WHO WILL BENEFIT FROM THIS TALK

TOPICS

WHAT YOU’LL LEAVE WITH

  • Windows Azure helps you build scalable web apps
  • using the approaches that you’re already familiar with.
  • Asynchronous patterns & techniques
  • Managing data access
  • Tuning application performance
  • Web app developers
  • who are already familiar with Windows Azure
  • with scaling needs.
s ynchronous design pattern
Synchronous Design Pattern
  • Each thread dedicated to one outstanding request
    • Block on each step of “the work” done for each request, then respond & repeat
  • This approach scales poorly
    • Each outstanding request is stored on a thread stack
    • Threads block even when there is work to be done
    • Adding a thread enables only one additional concurrent request

SQL Azure

Web App Front End

“The Work” #1

Client Request #1

Middle Tier

Client Response #1

WA Storage

Thread

Thread

Response #1

blocks

Client Request #2

Waiting…

Time passes…

asynchronous design pattern
Asynchronous Design Pattern
  • Each thread picks up work whenever it is ready
    • A thread handling one request may handle another before the first one completes
  • This approach scales well
    • Client requests tracked explicitly in app’s data structures
    • Threads never block while there is work to be done
    • Each thread can handle possibly many concurrent requests
  • But bookkeeping & synchronization can be difficult…

SQL Azure

Web App Front End

Client Request #1

“The Work” #1

Middle Tier

Client Response #1

WA Storage

Response #1

Thread

Thread

Client Request #2

“The Work” #2

Context

Client Response #2

Response #2

async await support simplifies bookkeeping
Async/await support simplifies bookkeeping
  • voidUploadImage(Stream image, CloudBlobdestBlob)
  • {
  • // Add image to list in SQL Azure
  • AddImageToSQLAzure(destBlob.Uri);
  • // Upload image to blob storage
  • UploadImageToBlob(image, destBlob);
  • }

asyncTaskUploadImageAsync(Stream image, CloudBlobdestBlob)

{

// Add image to list in SQL Azure

vart1 = AddImageToSQLAzureAsync(destBlob.Uri);

// Upload image to blob storage

vart2 = UploadImageToBlobAsync(image, destBlob);

awaitTaskEx.WhenAll(t1, t2);

}

But how do we make one of these?

creating async methods from begin end pairs
Creating async methods from begin/end pairs

asyncTaskUploadImageToBlobAsync (Stream image, CloudBlobdestBlob)

{

// Task.Factory.FromAsync method creates a Task or Task<T> to

// represent a Begin/End async invocation

awaitTask.Factory.FromAsync<Stream>(destBlob.BeginUploadFromStream,

destBlob.EndUploadFromStream,

image,

null);

}

voidUploadImageToBlob (Stream image, CloudBlobdestBlob)

{

destBlob.UploadFromStream(image);

}

asynchronous cloud support
Asynchronous Cloud Support
  • Async language features
    • .NET 4.0 Async CTP works with Azure if you copy AsyncCtpLibrary.dll
  • Windows Azure Storage Queues are useful for async communication between role instances
    • Built-in load balancing
    • Handles loss of individual role instances gracefully
  • Async designs may increase exposure to race conditions
    • Running at scale on commodity hardware means any role instance can fail at any time
    • Implement retries where appropriate
    • External state updates must be idempotent or transactional
managing data access
Managing Data Access
  • How to transfer data efficiently to and from clients?
    • There are different kinds of data; each has its own tricks
  • Trick #1: Get out of the way when you can
  • Send clients directly to blob storage for static content
    • Media (e.g. images, video)
    • Binaries (e.g. XAP, MSI, ZIP)
    • Data files (e.g. XML)

Blob

Storage

Hosted Compute

Hosted Compute

shared access signatures
Shared Access Signatures
  • Trick #2: Shared access signatures provide direct access to ACLed content
    • Can be time-bound or revoked on demand
  • Also works for write access (e.g. user-generated content)
  • http://blog.smarx.com/posts/shared-access-signatures-are-easy-these-days

2. Service prepares a Shared Access Signature (SAS) to X using the securely stored storage account key

1. “I am Bob & I want X”

Hosted Compute

Stg Key

3. Service returns SAS (signed HTTPS URL)

Blob Storage

4. Bob uses SAS to access X directly from Blob Storage for reduced latency & compute load

Non-public blob

(e.g. paid or ad-funded content)

X

serve blobs from the edge
Serve Blobs from the Edge
  • Trick #3: Serve public blobs from the edge with the Windows Azure CDN
  • Use the CDN if you expect multiple reads before content expiration
  • Reduces latency and load on central storage account

Possibly many hops or poor links

Few hops

CDN

Blob Storage

Closest Point of Presence

Public container

X

X

Blob header determines time-to-live at the edge

DNS name resolves to closest POP

windows azure content delivery network
Windows Azure Content Delivery Network
  • 24 global locations with 99.95% availability SLA
  • Enabling CDN access for your Windows Azure storage account
    • Enable the CDN in the devportal
    • It will generate a new URL for CDN-based access to your account
    • Same content, 2 URLs with different access patterns
      • CDN URL: http://azXXXX.vo.msecnd.net/images/myimage.png
      • WA Storage URL: http://myacct.blob.core.windows.net/images/myimage.png
  • CNAME mappings to CDN URLs
    • http://blog.smarx.com/posts/using-the-new-windows-azure-cdn-with-a-custom-domain
  • Smooth streaming is in CTP
managing cdn content expiration
Managing CDN Content Expiration
  • Default behavior is to fetch once and cache for up to 72 hrs
  • Modify cache control blob header to control the TTL
    • x-ms-blob-cache-control: public, max-age=<value in seconds>
    • Think hours, days or weeks
    • Higher numbers reduce cost and latency via CDN & downstream caches
  • Use versioned URLs to expire content on-demand
    • Enables easy rollback and A/B testing

HTML Served by App

Blob Storage

CDN

… <imgsrc="http://azXXXX.vo.msecnd.net/images/logo.2011-09-16.png" />…

… <imgsrc="http://azXXXX.vo.msecnd.net/images/logo.2011-08-01.png" />…

logo.2011-08-01.png

logo.2011-08-01.png

logo.2011-09-16.png

logo.2011-09-16.png

cdn for web apps
CDN for Web Apps
  • CDN supports your web app as an origin
    • Normal URL: http://foo.cloudapp.net/default.aspx
    • CDN URL: http://azXXXX.vo.msecnd.net/default.aspx
    • Cached from: http://foo.cloudapp.net/cdn/default.aspx
  • CNAMEs & HTTPS supported
  • http://blog.smarx.com/posts/using-the-windows-azure-cdn-for-your-web-application
  • You must modify cache control headers to set the ASP.NET OutputCache module to work well with the CDN
    • http://blogs.msdn.com/b/scicoria/archive/2011/07/10/hosted-service-as-a-windows-azure-cdn-origin-tips.aspx
windows azure traffic manager
Windows Azure Traffic Manager
  • Trick #4: Direct users to the service in the closest region with the Windows Azure Traffic Manager
  • CNAMEs supported
  • Useful for performance, business continuity, price, compliance & tax
  • Not the same as CDN
    • Not serving from the edge
    • Only DNS is cached (at client)

foo-us.cloudapp.net

Traffic Manager

foo.cloudapp.net

foo-europe.cloudapp.net

DNS response

Monitoring

Policies

1.2.3.4

foo-asia.cloudapp.net

traffic manager details
Traffic Manager Details
  • Multiple factors determine DNS resolution
    • Configured by Microsoft
      • Geo-IP mapping
      • Periodic performance measurement
    • Configured by service owner
      • Policy: Performance, Failover, Geo, Ratio
      • Monitoring
  • Currently in CTP
    • Only works in “production” slot but not yet intended for production use
    • No SLA or billing, and the Traffic Manager domain name will change

foo-us.cloudapp.net

foo-europe.cloudapp.net

Periodic GETs

Monitoring

/monitoring/testme.aspx

foo-asia.cloudapp.net

in memory caching
In-Memory Caching
  • Trick #5: Cache hot data in memory to avoid slower data-tier access
    • Session state (e.g. shopping cart) & immutable reference data (e.g. product catalog entries)
  • Caching tier will help you reduce latency and cost
    • Lower latency/higher throughput than data tier, especially under load

In-Memory Caching

SQL Azure

SQL Azure

Hosted Compute

Table Storage

Table Storage

windows azure appfabric caching
Windows Azure AppFabric Caching
  • AppFabric Caching is a hosted distributed cache as a service
    • Globally provisioned and managed by Microsoft with SLAs & pricing
    • Low latency, hosted per subregion for app affinity
    • AuthN/Z integrated with Access Control Service
  • Advantages
    • Simple to administer
    • ASP.NET session state and output cache providers
    • Same APIs as Windows Server AppFabric Cache
    • Client-local near cache for hot data without serialization costs
partitioning sharding
Partitioning & Sharding
  • Trick #6: Partition & shard at the data tier
  • SQL Azure single DB limits
    • 50 GB capacity, will expand over time
    • Overuse of more than one node’s worth of resources may result in throttling http://social.technet.microsoft.com/wiki/contents/articles/sql-azure-connection-management.aspx
  • Windows Azure Storage scalability targets
    • Each account supports 100 TB capacity, 5K transactions/sec, 3 Gbps bandwidth
    • 500 messages/sec per queue
    • 500 entities/sec per table partition (multiple partitions permitted per table)
    • 60 MB/sec per blob

WA Storage Acct

WA Storage Acct

Partitioned Table

Partitioned Table

Hosted Compute

Queue

Blob

Queue

Blob

WA Storage Acct

Partitioned Table

Queue

Blob

sql azure federations
SQL Azure Federations
  • Sharding is…
    • a pattern that scales out data tier access by partitioning data and queries across multiple servers
    • a design choice that impacts the app, schema and DBA
  • Federation is SQL Azure’s new native sharding implementation
    • Distributes data across databases (federation members)
    • Routes queries to the correct federation members
    • Enables dynamic repartitioning without downtime
  • SQL Azure Federation is in CTP now, will release in 2011
  • http://social.technet.microsoft.com/wiki/contents/articles/2281.aspx
basic performance tuning
Basic Performance Tuning
  • Tune Windows Azure applications just as you would on-premises applications
    • Measure & optimize where it makes a difference
  • Windows Azure uses Full IIS for web roles in the 1.3+ SDK
    • Startup admin tasks using WebPI can install up-to-date extensions as desired
    • Startup admin tasks using AppCmd can configure IIS as desired
  • Basic tips
    • Build in release mode (not debug mode) for production
    • Do not enable IntelliTrace or Failed Request Tracing in production
  • Tune role instance counts and consider dynamic scaling
advanced performance tuning
Advanced Performance Tuning
  • Enable compression for additional dynamic content types

<add mimeType="application/json" enabled="true" />

<add mimeType="application/json; charset=utf-8" enabled="true" />

    • Office document formats
  • Tune application pool recycling to suit your workload
    • Modify default schedule to avoid peak times
      • http://blog.smarx.com/posts/controlling-application-pool-idle-timeouts-in-windows-azure
    • Measure and eliminate memory leaks if footprint grows over time
  • Move ASP.NET cache to the resource disk for more space
  • Tune Windows Azure Diagnostics settings
summary
Summary

Blob Storage

Cache control

Versioned URLs

CDN

  • Approach WA apps like you would on-premises apps
  • Use rich platform features in Windows Azure to tune for the cloud too

Public

Public

Web App

Private

Traffic Mgr

Asynchronous Hosted Compute

Asynchronous Hosted Compute

AppFabric Caching

Shared Access Signatures

Table Storage

Table Storage

Synchronous Hosted Compute

Stg Key

Tuning

SQL Azure

SQL Azure

SQL Azure

Sharding

for more information
For more information

RELATED SESSIONS

DOCUMENTATION & ARTICLES

Tutorials for improving performance on Windows Azure: http://www.microsoft.com/windowsazure/learn/improve-performance/

Building Global and Highly Available Services Using Windows Azure

Building IIS and ASP.NET Applications with the Power of Async

Building Parallelized Applications with .NET and Visual Studio

Optimize Your Website Using ASP.NET and IIS8

The Zen of Async: Best Practices for Best Performance

CONTACT: matthew.kerner@microsoft.com

feedback and q uestions http forums dev windows com session f eedback http bldw in sessionfeedback
thank you

Feedback and questions http://forums.dev.windows.com

Session feedbackhttp://bldw.in/SessionFeedback

slide25

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