building scalable applications with azure cloud services and service bus
DESCRIPTION
HDNUG.org presentation "Building Scalable Applications with Azure Cloud Services and Service Bus." More details at http://www.kcode.me/#/Talks.TRANSCRIPT
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)
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Execution Models
Web sitesMobile servicesVirtual machinesCloud services
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
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
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Cloud Service Project
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
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
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Windows Azure Scalability Posterhttp://msdn.microsoft.com/library/azure/xx130451.aspx
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
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
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Sample Queue
Providers Consumers
N+2
NN+1
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Sample Topic
Providers Consumers
Topic
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
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
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Brokered Message
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
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
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
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Loosely Coupled Architecture
TestingEasier transition in switching implementationEasier migration to another platform
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Useful Design Patterns
Isolate APIs with interfaceFaçade PatternDependency Injection ContainerFactories
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
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
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
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Scaling
ConfigurationManualAPIAuto Scale
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Scale by CPU
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Scale by Queue
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Demo Time
Node.js web roleC# worker role
Evolving Exploration Software © Bluware, Inc | 713-335-1500 | www.bluware.com
Questions?
Slides and code available at www.kcode.me