Two Roles a Queue Azure Web Roles Worker
![Two Roles a Queue Azure Web Roles, Worker Roles, and Queues Boston Azure User Two Roles a Queue Azure Web Roles, Worker Roles, and Queues Boston Azure User](https://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-1.jpg)
Two Roles a Queue Azure Web Roles, Worker Roles, and Queues Boston Azure User Group http: //bostonazure. org @bostonazure Boston West Toastmasters http: //bwtoastmasters. com Bill Wilder http: //blog. codingoutloud. com @codingoutloud Not here with my day job Only Bill’s personal views Copyright (c) 2010, Bill Wilder
![Goal: Build software systems where… • • Time-to-market is short Effort focuses on business Goal: Build software systems where… • • Time-to-market is short Effort focuses on business](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-2.jpg)
Goal: Build software systems where… • • Time-to-market is short Effort focuses on business functionality Development is highly productive Cost structure is a good fit Downtime is not necessary Scale is efficient Modification is straight-forward Infrastructure is not a limiting factor
![Agenda for Roles & Queues • • • What are Roles and Queues? What Agenda for Roles & Queues • • • What are Roles and Queues? What](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-3.jpg)
Agenda for Roles & Queues • • • What are Roles and Queues? What tools are needed? Why are Roles important? Why are Queues important? Why does Rn Qn Rn matter? How do I Build, Debug, and Deploy?
![Two Concepts 1. Roles –Web Roles –Worker Roles 2. Queues Two Concepts 1. Roles –Web Roles –Worker Roles 2. Queues](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-4.jpg)
Two Concepts 1. Roles –Web Roles –Worker Roles 2. Queues
![Web Roles are a lot like Web Pages ASP. NET Page Build using ASP. Web Roles are a lot like Web Pages ASP. NET Page Build using ASP.](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-5.jpg)
Web Roles are a lot like Web Pages ASP. NET Page Build using ASP. NET, MVC Runs in IIS 7 Visible to Internet Good to handle interactive users Good for hosting Web API (WCF) Language Agnostic Web Role Worker Role
![Queue Queue](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-6.jpg)
Queue
![Key Pattern: Roles + Queues Web Role (IIS) Worker Role Queues Blobs Tables Key Pattern: Roles + Queues Web Role (IIS) Worker Role Queues Blobs Tables](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-7.jpg)
Key Pattern: Roles + Queues Web Role (IIS) Worker Role Queues Blobs Tables
![Canonical Example: Thumbnails Web Role (IIS) Worker Role Queues Blobs Tables Canonical Example: Thumbnails Web Role (IIS) Worker Role Queues Blobs Tables](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-8.jpg)
Canonical Example: Thumbnails Web Role (IIS) Worker Role Queues Blobs Tables
![Key Pattern: Roles + Queues Web Role (IIS) Worker Role Queues Key Pattern: Roles + Queues Web Role (IIS) Worker Role Queues](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-9.jpg)
Key Pattern: Roles + Queues Web Role (IIS) Worker Role Queues
![Pre-Azure Development Tool Stack • Visual Studio • C#, VB. NET, F#, … • Pre-Azure Development Tool Stack • Visual Studio • C#, VB. NET, F#, … •](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-10.jpg)
Pre-Azure Development Tool Stack • Visual Studio • C#, VB. NET, F#, … • . NET Runtime
![Azure Development Tool Stack • • Visual Studio C#, VB. NET, F#, …. NET Azure Development Tool Stack • • Visual Studio C#, VB. NET, F#, …. NET](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-11.jpg)
Azure Development Tool Stack • • Visual Studio C#, VB. NET, F#, …. NET Runtime Dev Fabric, Azure Toolkit , Azure SDK • Plus… • Could be non-Visual Studio, non-. NET-based • REST access to all Azure Services
![Pre-Azure Server Stack • • • . NET Runtime (3. 5) Windows Server 2008, Pre-Azure Server Stack • • • . NET Runtime (3. 5) Windows Server 2008,](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-12.jpg)
Pre-Azure Server Stack • • • . NET Runtime (3. 5) Windows Server 2008, IIS 7 Windows Communication Foundation (WCF) SQL Server MSMQ ASP. NET, ASP. NET MVC
![Azure Server Stack • • • . NET Runtime (3. 5) Windows Server 2008, Azure Server Stack • • • . NET Runtime (3. 5) Windows Server 2008,](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-13.jpg)
Azure Server Stack • • • . NET Runtime (3. 5) Windows Server 2008, IIS 7 Windows Communication Foundation (WCF) SQL Server SQL Azure SQL Server Azure Blobs null Azure Table Storage MSMQ Azure Queues ASP. NET, ASP. NET MVC Azure Web Role null Worker Roles
![Default. aspx. cs • public partial class _Default : System. Web. UI. Page • Default. aspx. cs • public partial class _Default : System. Web. UI. Page •](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-14.jpg)
Default. aspx. cs • public partial class _Default : System. Web. UI. Page • { • protected void Page_Load(…) • { • if (Page. Is. Post. Back) • { • throw new Exception( • "goodbye cloud"); • }
![Global. asax. cs • static int x = 0; • protected void Application_Error(object sender, Global. asax. cs • static int x = 0; • protected void Application_Error(object sender,](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-15.jpg)
Global. asax. cs • static int x = 0; • protected void Application_Error(object sender, Event. Args e) • { Exception ex = Server. Get. Last. Error(); • if (ex. Get. Type() == typeof(Http. Exception)) { … } • Response. Write(ex. Message); • Server. Clear. Error(); • • } if (x % 3 == 0) Response. Redirect("default. aspx"); • http: //crashtestdummy. cloudapp. net/
![Pre-Azure Operational Concerns • • • Buying hardware Cap. Ex Provisioning Servers Configuring Servers Pre-Azure Operational Concerns • • • Buying hardware Cap. Ex Provisioning Servers Configuring Servers](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-16.jpg)
Pre-Azure Operational Concerns • • • Buying hardware Cap. Ex Provisioning Servers Configuring Servers and Services Patching the Operating System (Human) Ops Resource Intensive
![Azure Operational Concerns • • • Buying hardware null Cap. Ex Variable cost / Azure Operational Concerns • • • Buying hardware null Cap. Ex Variable cost /](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-17.jpg)
Azure Operational Concerns • • • Buying hardware null Cap. Ex Variable cost / Utility pricing Provisioning Servers null Configuring Servers and Services null Patching the Operating System null (Human) Ops Resource Intensive null + Communication paths reduced
![Key Pattern: Roles + Queues Web Role (IIS) Worker Role Queues Key Pattern: Roles + Queues Web Role (IIS) Worker Role Queues](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-18.jpg)
Key Pattern: Roles + Queues Web Role (IIS) Worker Role Queues
![Roles and Queue • Allow loosely coupled workflow between roles • Messages not processed Roles and Queue • Allow loosely coupled workflow between roles • Messages not processed](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-19.jpg)
Roles and Queue • Allow loosely coupled workflow between roles • Messages not processed strictly FIFO • Queue length (and trend) is key metric for tuning Role deployment numbers
![n Roles Key Pattern: + Rn Qn Rn n Queues Worker Role Type 1 n Roles Key Pattern: + Rn Qn Rn n Queues Worker Role Type 1](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-20.jpg)
n Roles Key Pattern: + Rn Qn Rn n Queues Worker Role Type 1 Web Role (IIS) Role (IIS) Queues Worker Role Type 2
![Azure Queues by the Numbers 100% = Reliability of message delivery 30 seconds = Azure Queues by the Numbers 100% = Reliability of message delivery 30 seconds =](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-21.jpg)
Azure Queues by the Numbers 100% = Reliability of message delivery 30 seconds = default “invisibility window” 8 KB = max size of a queued item 7 days = max length an item can stay on queue 500 = approx number of transactions a queue can handle per second • N = number of queues you can have (N >> 1) • • •
![Out is the new Up • Scaling Out has hard limits at CPU, Memory Out is the new Up • Scaling Out has hard limits at CPU, Memory](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-22.jpg)
Out is the new Up • Scaling Out has hard limits at CPU, Memory – Architecturally more limiting
![Rn Qn Rn requires Idempotent • If we do a task twice, end result Rn Qn Rn requires Idempotent • If we do a task twice, end result](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-23.jpg)
Rn Qn Rn requires Idempotent • If we do a task twice, end result same as if we did it once
![Rn Qn Rn enables Responsive • Response to interactive users is as fast as Rn Qn Rn enables Responsive • Response to interactive users is as fast as](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-24.jpg)
Rn Qn Rn enables Responsive • Response to interactive users is as fast as a work request can be persisted • Time consuming work done off-line • Same total resource consumption, better subjective experience
![Rn Qn Rn enables Scalable • Loosely coupled, concern-independent scaling • Blocking is Bane Rn Qn Rn enables Scalable • Loosely coupled, concern-independent scaling • Blocking is Bane](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-25.jpg)
Rn Qn Rn enables Scalable • Loosely coupled, concern-independent scaling • Blocking is Bane of Scalability – Decoupled front/back ends insulate from other system issues if… – Twitter down – Email server unreachable – Order processing partner doing maintenance – Internet connectivity interruption
![Rn Qn Rn enables Resilient • “Plan for failure” • There will be role Rn Qn Rn enables Resilient • “Plan for failure” • There will be role](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-26.jpg)
Rn Qn Rn enables Resilient • “Plan for failure” • There will be role restarts • Bake in handling of restarts – Not an exception! – Restarts are routine, system “just keeps working” • Change the “service” topology by adding or removing role instances… – Without service interruption
![Common Problems • Hard to upgrade without downtime • Wasteful to provision for peak Common Problems • Hard to upgrade without downtime • Wasteful to provision for peak](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-27.jpg)
Common Problems • Hard to upgrade without downtime • Wasteful to provision for peak load • Time consuming to add more dev or test environments
![What’s Going Down? Typical Site Operating System Upgrade Application Update / Deploy Change Topology What’s Going Down? Typical Site Operating System Upgrade Application Update / Deploy Change Topology](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-28.jpg)
What’s Going Down? Typical Site Operating System Upgrade Application Update / Deploy Change Topology Hardware Failure Software Bug / Crash / Failure Security Patch An Azure Role Azure Site
![Scale Out easier to Spread Out • Scale out systems better suited for geographic Scale Out easier to Spread Out • Scale out systems better suited for geographic](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-29.jpg)
Scale Out easier to Spread Out • Scale out systems better suited for geographic distribution – More efficient and flexible because more granular – Hard for a mega-machine to be in more than one place – Failure need not be binary
![Azure’s Abstraction • Code that knows about failover, other computers, environments, … – Does. Azure’s Abstraction • Code that knows about failover, other computers, environments, … – Does.](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-30.jpg)
Azure’s Abstraction • Code that knows about failover, other computers, environments, … – Does. Not. Exist. in your application code • Azure’s App. Fabric handles • So Roles support many properties – Azure allows for a clean implementation or Roles
![These capabilities are not all new… right? These capabilities are not all new… right?](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-31.jpg)
These capabilities are not all new… right?
![Not new, but… Not new, but…](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-32.jpg)
Not new, but…
![Accessible to us mere mortals Less complex, more cost-effective, competitive pressure: everyone’s doing it Accessible to us mere mortals Less complex, more cost-effective, competitive pressure: everyone’s doing it](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-33.jpg)
Accessible to us mere mortals Less complex, more cost-effective, competitive pressure: everyone’s doing it
![Advanced Queue Topics • • • Code for retries – Plan to fail Poison Advanced Queue Topics • • • Code for retries – Plan to fail Poison](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-34.jpg)
Advanced Queue Topics • • • Code for retries – Plan to fail Poison Messages Exception handling Fully utilize Roles – complexity trade-off Async notification of new Queue items
![Advanced Worker Role Topics • Full utilization of a WR instance is more work Advanced Worker Role Topics • Full utilization of a WR instance is more work](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-35.jpg)
Advanced Worker Role Topics • Full utilization of a WR instance is more work – Message stays in queue for 7 days – You pay by instance, not resource use within • Tactics… – Read >1 message from queue at a time – Have multiple message types handled in one worker role – Build multi-threaded Worker Role • Build simple “scale with the config file” systems – Is time-to-market more imp than deployment / run costs? – Trade off scale efficiency, maintainability, time-to-market • Business Decisions!
![Silver Bullet? • Question: Does Azure make my application scale automatically? Silver Bullet? • Question: Does Azure make my application scale automatically?](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-36.jpg)
Silver Bullet? • Question: Does Azure make my application scale automatically?
![Closing thought • Do we really need “the cloud” for all these great properties? Closing thought • Do we really need “the cloud” for all these great properties?](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-37.jpg)
Closing thought • Do we really need “the cloud” for all these great properties? • Does (cloud == scalability + operational simplicity + cost savings + fast time-to-market)?
![“These go to eleven” –Nigel Tufnel The cloud is an amplifier – emerging as “These go to eleven” –Nigel Tufnel The cloud is an amplifier – emerging as](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-38.jpg)
“These go to eleven” –Nigel Tufnel The cloud is an amplifier – emerging as best system of software services + patterns + tools + ecosystem for tomorrow’s systems
![Visualizer Visualizer](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-39.jpg)
Visualizer
![• http: //baugfirestarter. cloudapp. net/ • http: //bostonazuresample. cloudapp. net/ • Narrative for • http: //baugfirestarter. cloudapp. net/ • http: //bostonazuresample. cloudapp. net/ • Narrative for](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-40.jpg)
• http: //baugfirestarter. cloudapp. net/ • http: //bostonazuresample. cloudapp. net/ • Narrative for Lab 1: • http: //hmbl. me/1 H 4 ZVZ • (about breaks…)
![Lab Time Lab Time](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-41.jpg)
Lab Time
![Lab Time Lab Time](http://slidetodoc.com/presentation_image/8e0b212ec997b7abb936bb3c39b5cf27/image-42.jpg)
Lab Time
- Slides: 42