building scalable applications with azure cloud services and service bus

29
Building Scalable Applications with Azure Cloud Services and Service Bus

Upload: kachermb

Post on 21-Jun-2015

387 views

Category:

Software


0 download

DESCRIPTION

HDNUG.org presentation "Building Scalable Applications with Azure Cloud Services and Service Bus." More details at http://www.kcode.me/#/Talks.

TRANSCRIPT

Page 1: Building Scalable Applications with Azure Cloud Services and Service Bus

Building Scalable Applications with Azure Cloud Services and Service Bus

Page 2: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Goals

VS 2013 Azure integration and ease of useCloud Services and Service Bus FeaturesLoosely Coupled designScale Out (not up)Easy to scale, resistant to failurePerformant (serialization, caching, batching, efficient code/frameworks)

Page 3: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Execution Models

Web sitesMobile servicesVirtual machinesCloud services

Page 4: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Cloud Services

Platform as a Service (PaaS)Platform infrastructure managed by AzureUser provides configurationConsist of 1-n worker/web roles

Page 5: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Roles

Two Types of Roles–Web Role: IIS enabled–Worker Role: IIS disabled

A role consists of 1-n identical instancesA deployment contains 1-n RolesEach role has an agent

Page 6: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Cloud Service Project

Page 7: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Instances

Non-durable virtual machine (VM)New instances can be created by a roles agent– Failure in VM– Scaling

Page 8: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Demo

Create Cloud Service and debug in Visual StudioEnvironment– Visual Studio 2013 Update 2– Windows Azure SDK 2.3– Node V0.10.26– Node.Js Tools for VS 2013 Beta

Page 9: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Windows Azure Scalability Posterhttp://msdn.microsoft.com/library/azure/xx130451.aspx

Page 10: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Azure Service Bus

Queues– reliable, persistent FIFO guaranteed– 1-n competing consumers

Topics– Publish/subscribe messaging (fan out)– Component exchange messages through topic– Supports filter registration

Page 11: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Queue Design

Receiving messages– Polling (pull based)– Queue listeners (push based)

Scale role instances to handle workloadBatch put/get itemsUse multiple queues for higher throughput

Page 12: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Sample Queue

Providers Consumers

N+2

NN+1

Page 13: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Sample Topic

Providers Consumers

Topic

Page 14: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Queue Receive Modes

PeekLock– Default mode– After message received, request sent back

ReceiveAndDelete– Both steps in single request– Less throughput– Can lose messages

Page 15: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Using Service Bus

Do not create and close queue/topic clientsBatch items and prefetchingUser asynchronous requestsPartitioning

Page 16: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Brokered Message

Page 17: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Demo Time!

BrokeredMessage, Serialization and Send/Receive

Requirement: Service Bus Namespace Connection StringGo to www.manage.windowsazure.com

Page 18: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Easy to Scale, Resistant to Failure

Avoid single point of failureScale-out not scale-upBe statelessHandle failure gracefully

Page 19: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Error Handling

Handle dropped connectionsHandle transient failures (retry/reconnect)Other failures (log, report, and notify user)If possible, fall back to a different service or workflow

Page 20: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Loosely Coupled Architecture

TestingEasier transition in switching implementationEasier migration to another platform

Page 21: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Useful Design Patterns

Isolate APIs with interfaceFaçade PatternDependency Injection ContainerFactories

Page 22: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Bang for Your Buck!

Batch network calls if appropriateProper serializationChoose frameworks wiselyDon’t server static content from website/web role

Page 23: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Blob Storage

Less load on serverFaster IO than SQLCheapest Azure storageUser for static content >100 kB

Page 24: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Azure Cache Service

Distributed In-memoryPersists during application restartsExpiration: never, absolute, slidingNotifications: AddItem, ReplaceItem, RemoveItemBuilt in back-up

Page 25: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Scaling

ConfigurationManualAPIAuto Scale

Page 26: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Scale by CPU

Page 27: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Scale by Queue

Page 28: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Demo Time

Node.js web roleC# worker role

Page 29: Building Scalable Applications with Azure Cloud Services and Service Bus

Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com

Questions?

[email protected]

Slides and code available at www.kcode.me