SlideShare a Scribd company logo
Azure Cloud Patterns
About Me
• Software architect, consultant and instructor
• Software Engineering Lecturer @ Ruppin Academic Center
• Technology addict
• .NET and Native Windows Programming
@tamir_dresher
tamirdr@codevalue.net
http://www.TamirDresher.com.
Cloud Patterns
http://en.wikipedia.org/wiki/List_of_cloud_types
Agenda
• What are Cloud Patterns
• Queue Centric
• Poison Messages
• Retry Logic
• Circuit Breaker
• Cache Aside
What are Cloud Patterns
• Architectural Patterns:
“A design pattern in architecture and 
computer science is a formal way of 
documenting a solution to a design problem 
in a particular field of expertise”
(http://en.wikipedia.org/wiki/Architectural_patterns)
Meet The Problem
DevGeek Coffee Shop
DevGeek Coffee Shop
• DevGeek Coffee is a well known and
established coffee shop
• In business for 20 years
• Lately, with the increasing competition,
sales are dropping
• Lets Help!
DevGeek Coffee Shop - Operations
coffee
DevGeek Coffee Shop - Operations
coffee#!$@
What does this has to do with software?
• Cashier == Server
• Basically, this is a scalability issue
• Running in the cloud (potentially) makes
scaling problem appear faster
Scale Up
• Add More Resources to a Node
• Faster cashier
– Better CPU to the server
– More Memory
• Faster Coffee machine
– Use a better algorithm/service
Everything has a limit
MoneyMoney
CPUCPU
MEMMEMBANDWIDTH
BANDWIDTH
StorageStorage
Scale out
• Add More Nodes
– More Cashiers
• Load Distribution
– Round Robin
– Performance
– Other (location, expertise, etc)
Azure Traffic Manager
Meet The Problem 2
DevGeek Coffee Shop
DevGeek Coffee Shop – The clients complaints
• Long standing
• Sometimes orders gets lost
• Sometimes the line is so long that the
workers close the doors
DevGeek Coffee Shop – Latency and throughput
• Latency is a time interval between the
stimulation and response
– Time between ordering and receiving the coffee
• Throughput is the number of requests that
can be served per unit time
DevGeek Coffee Shop – Aroma model
coffee
.
Message Centric
Web Sites worker role
:
:
worker roleweb role
Message Centric – Load Leveling
:
:
Request Received at
variable rate
Messages Processed
at consistent rate
Message Centric – Resilency
:
:
X
X
Message Centric – Delayed Processing
:
:
Azure Queuing Options
• Azure Storage Queues
– Simple, Reliable, Persistent Queue
– Max 200TB and 7 days TTL per message
• Azure Service Bus
– Broader capabilities: publish/subscribe,
remoting, integration patterns
– Max 80GB and unlimited TTL per message
http://msdn.microsoft.com/en-us/library/hh767287.aspx
Azure Service Bus – Queueing
Service Bus Messaging - Queue
• Two parts:
1. key/value properties
2. binary message body.
• Example: a sales application
sends message
properties: 
• *Seller="Ava"  
• *Amount=10000.
• body : The sale's signed contract scanned image
Producer Consumer
Demo
C2
2
1
2
1
1
1
1
1
Removing Poison Messages
1
1
1
1
2
1
2
1
334
0
4
0
Producers Consumers
3
0
3
0
2. GetMessage(Q, 30 s)  msg 2
1. GetMessage(Q, 30 s)  msg 1
1
1
1
1
2
1
2
1
1
0
1
0
2
0
2
0
P2
P1
C1
C2
P2
P1
C1
Removing Poison Messages
34
0
4
0
Producers Consumers
1
1
1
1
2
1
2
1
2. GetMessage(Q, 30 s)  msg 2
3. C2 consumed msg 2
4. DeleteMessage(Q, msg 2)
7. GetMessage(Q, 30 s)  msg 1
1. GetMessage(Q, 30 s)  msg 1
5. C1 crashed
1
1
1
1
2
1
2
1
6. msg1 visible 30 s after Dequeue3
0
3
0
1
2
1
2
1
1
1
1
1
2
1
2
C2
P2
P1
C1
Removing Poison Messages
34
0
4
0
Producers Consumers
1
2
1
2
2. Dequeue(Q, 30 sec)  msg 2
3. C2 consumed msg 2
4. Delete(Q, msg 2)
7. Dequeue(Q, 30 sec)  msg 1
8. C2 crashed
1. Dequeue(Q, 30 sec)  msg 1
5. C1 crashed
10. C1 restarted
11. Dequeue(Q, 30 sec)  msg 1
12. DeliveryCount > 2
13. msg1.DeadLetter
1
2
1
2
6. msg1 visible 30s after Dequeue
9. msg1 visible 30s after Dequeue
3
0
3
0
1
3
1
3
1
2
1
2
1
3
1
3
Service Bus Messaging – Dead letters
• the name of the sub-queue is [queueName]/
$DeadLetterQueue
• The path can be obtained using the
FormatDeadLetterPath method of the
QueueClient
• Can be consumed by any other consumer
and check the messages, log them etc.
Priority Queue
• The queue may hold message with different
priorities (3-High, 1-Low)
Web Sites
worker role
:
:
worker roleweb role
:
Priority Queue
Application
Priority Queue
Application
Meet The Problem 3
DevGeek Coffee Shop
DevGeek Coffee Shop – The clients complaints
1. Sometimes the soy milk ran out
2. the barista calls to the storeroom
3. The line is busy
4. The barista move to next order
5. Customer receive an order cancellation
Transient Faults
• “Transient fault is a fault that is no longer
present if power is disconnected for a short
time and then restored.” (http
://en.wikipedia.org/wiki/Transient_fault#Transient_fault)
• Many faults in connectivity to cloud are
transient by nature
• Commonly occur when connecting to
service or database
Retry Pattern
• If at first you don’t succeed, try try again
(William Edward Hickson)
• Retry Logic
– Linear – every fixed amount of time
– Exponential – if the server is heavy-used
(throttling) we don’t want to flood it
immediate….1 sec….5 seconds….etc.
– Other
Operation With Basic Retry
    int currentRetry = 0;
    while (currentRetry < MaxRetries)
    {
        try
        {
            // Calling external service.
            await TransientOperationAsync();
        }
        catch (Exception ex)
        {
            currentRetry++;
 
            // Check if the exception thrown was a transient exception
            if (!IsTransient(ex))
            {
                // If this is not a transient error 
                // or we should not retry re-throw the exception. 
                throw;
            }
        } 
        await Task.Delay(TimeBetweenRetries);
    }
Retry Pattern – Solutions
• Azure Storage IRetryPolicy
• Azure Service Bus RetryPolicy
IRetryPolicy noRetryPolicy = new NoRetry();
BlobRequestOptions requestOptions = new
BlobRequestOptions()
{
RetryPolicy = noRetryPolicy,
};
MessagingFactory factory = MessagingFactory.Create();
factory.RetryPolicy = RetryExponential.Default;
factory.RetryPolicy = RetryPolicy.NoRetry;
The Transient Fault Handling Application Block
var retryPolicy =
new Incremental(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));
retryPolicy.Retrying += (sender, args) => {
Trace.WriteLine(args.LastException, "Information");
};
try {
retryPolicy.ExecuteAction(() =>
{
TranisentErrorOperation();
});
}
catch (Exception) {
// All the retries failed.
}
http://msdn.microsoft.com/en-us/library/hh680934(v=pandp.50).aspx
Circuit Breaker
Retry Logic – Not Always Not all The time
• Baristas keeps retrying/failing – Time
Consuming
• Maybe we can call someone else?
• The remote service still might get flooded
• If a failure is not transient, we wish that next
attempts fail immediately
Circuit Breaker
• Circuit Breaker pattern prevent repeatedly
trying to execute an operation that is likely
to fail
• continue without waiting for the fault to be
rectified
• Prevents wasting valuable resources
because of the wait
Circuit Breaker
• The Circuit Breaker is a proxy
• Monitor the number of recent failures
• Decide if to proceed or do something else
– Throw exception
– Try different destination
Circuit Breaker States
Closed Open
Success
Fail [threshold reached]
Half
Open
Retry Timeout
Fail
Success
Fail [under threshold]
Cache Aside
Deja vu
• We fetch the same data
• We run the same calculation
• We query the same service
Cache Aside
Azure Caching
• Azure Managed Cache
• Azure Redis Cache
• In-Role Cache
In Role Cache – co-located
In Role Cache - Dedicated
InRole Cache
Summery
• What are Cloud Patterns
• Queue Centric
• Poison Messages
• Retry Logic
• Circuit Breaker
• Cache Aside
References
• P&P Cloud Design Patterns -
http://msdn.microsoft.com/en-us/library/dn568099.aspx
• http://cloudpatterns.org/
• Cloud Architecture Patterns
Azure Cloud Patterns
Images References
1. http://en.wikipedia.org/wiki/List_of_cloud_types
2. http://www.freedigitalphotos.net/images/Emotions_g96-
Arms_Up_Character_Shows_Shock_And_Surprise_p142355.html
3. http://www.freedigitalphotos.net/images/Hot_drinks_g184-
Coffee_In_White_Cup_p96634.html

More Related Content

What's hot (20)

PPTX
GWAB 2015 - Data Plaraform
Marcelo Paiva
 
PDF
Software Development with Apache Cassandra
zznate
 
PDF
Getting Started with MariaDB with Docker
MariaDB plc
 
PPTX
Oracle Coherence
Mustafa Ahmed
 
PPT
Applications of Virtual Machine Monitors for Scalable, Reliable, and Interact...
Amr Awadallah
 
PDF
Distributed applications using Hazelcast
Taras Matyashovsky
 
PPTX
From cache to in-memory data grid. Introduction to Hazelcast.
Taras Matyashovsky
 
PDF
Introduction to hazelcast
Emin Demirci
 
PPT
High Performance Computing - Cloud Point of View
aragozin
 
PDF
Overcoming the Top Four Challenges to Real-Time Performance in Large-Scale, D...
SL Corporation
 
PPTX
Virtualizing Latency Sensitive Workloads and vFabric GemFire
Carter Shanklin
 
PPTX
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
Jovan Popovic
 
PPTX
DV01 Ten Things You Always Wanted to Know About Windows Azure But Were Afraid...
Ronald Widha
 
PDF
Ari Zilka Cluster Architecture Patterns
deimos
 
PDF
Scaling data on public clouds
Liran Zelkha
 
PDF
Client Drivers and Cassandra, the Right Way
DataStax Academy
 
PPTX
Object oriented design patterns for distributed systems
Jordan McBain
 
PDF
Using all of the high availability options in MariaDB
MariaDB plc
 
PDF
Dr and ha solutions with sql server azure
MSDEVMTL
 
PPTX
Virtualization vs. Cloud Computing: What's the Difference?
Bangladesh Network Operators Group
 
GWAB 2015 - Data Plaraform
Marcelo Paiva
 
Software Development with Apache Cassandra
zznate
 
Getting Started with MariaDB with Docker
MariaDB plc
 
Oracle Coherence
Mustafa Ahmed
 
Applications of Virtual Machine Monitors for Scalable, Reliable, and Interact...
Amr Awadallah
 
Distributed applications using Hazelcast
Taras Matyashovsky
 
From cache to in-memory data grid. Introduction to Hazelcast.
Taras Matyashovsky
 
Introduction to hazelcast
Emin Demirci
 
High Performance Computing - Cloud Point of View
aragozin
 
Overcoming the Top Four Challenges to Real-Time Performance in Large-Scale, D...
SL Corporation
 
Virtualizing Latency Sensitive Workloads and vFabric GemFire
Carter Shanklin
 
Tarabica 2019 (Belgrade, Serbia) - SQL Server performance troubleshooting
Jovan Popovic
 
DV01 Ten Things You Always Wanted to Know About Windows Azure But Were Afraid...
Ronald Widha
 
Ari Zilka Cluster Architecture Patterns
deimos
 
Scaling data on public clouds
Liran Zelkha
 
Client Drivers and Cassandra, the Right Way
DataStax Academy
 
Object oriented design patterns for distributed systems
Jordan McBain
 
Using all of the high availability options in MariaDB
MariaDB plc
 
Dr and ha solutions with sql server azure
MSDEVMTL
 
Virtualization vs. Cloud Computing: What's the Difference?
Bangladesh Network Operators Group
 

Similar to Azure Cloud Patterns (20)

PPTX
Cloud patterns - NDC Oslo 2016 - Tamir Dresher
Tamir Dresher
 
PPTX
Azure architecture design patterns - proven solutions to common challenges
Ivo Andreev
 
PPT
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
John Staveley
 
PPTX
Cloud Messaging with NServiceBus and Microsoft Azure
Particular Software
 
PPTX
Azure App Service Deep Dive
Azure Riyadh User Group
 
PPTX
The impact of cloud NSBCon NY by Yves Goeleven
Particular Software
 
PPT
Design patterns and plan for developing high available azure applications
Himanshu Sahu
 
PPTX
Serhiy Kalinets "Embracing architectural challenges in the modern .NET world"
Fwdays
 
PPT
Arc Ready Cloud Computing
Philip Wheat
 
PDF
Cloud Design Patterns
Carlos Mendible
 
PDF
Middleware in the cloud platform-v2
Hammad Rajjoub
 
PPTX
Acsug scalable windows azure patterns
Nikolai Blackie
 
PPTX
Cloud architecture
Mahmoud Moussa
 
PPTX
A serverless IoT Story From Design to Production and Monitoring
Moaid Hathot
 
PPTX
A serverless IoT story from design to production and monitoring
CodeValue
 
PPTX
Migrating Customers to Microsoft Azure: Lessons Learned From the Field
Ido Flatow
 
PPTX
Data stream processing and micro service architecture
Vyacheslav Benedichuk
 
PPTX
Upgrade my PaaS
Derek Bingham
 
PPTX
Azure Messaging Services 2
Azure Riyadh User Group
 
PPTX
.NET Fest 2019. Alex Pshul. When IoT Meets Serverless
NETFest
 
Cloud patterns - NDC Oslo 2016 - Tamir Dresher
Tamir Dresher
 
Azure architecture design patterns - proven solutions to common challenges
Ivo Andreev
 
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
John Staveley
 
Cloud Messaging with NServiceBus and Microsoft Azure
Particular Software
 
Azure App Service Deep Dive
Azure Riyadh User Group
 
The impact of cloud NSBCon NY by Yves Goeleven
Particular Software
 
Design patterns and plan for developing high available azure applications
Himanshu Sahu
 
Serhiy Kalinets "Embracing architectural challenges in the modern .NET world"
Fwdays
 
Arc Ready Cloud Computing
Philip Wheat
 
Cloud Design Patterns
Carlos Mendible
 
Middleware in the cloud platform-v2
Hammad Rajjoub
 
Acsug scalable windows azure patterns
Nikolai Blackie
 
Cloud architecture
Mahmoud Moussa
 
A serverless IoT Story From Design to Production and Monitoring
Moaid Hathot
 
A serverless IoT story from design to production and monitoring
CodeValue
 
Migrating Customers to Microsoft Azure: Lessons Learned From the Field
Ido Flatow
 
Data stream processing and micro service architecture
Vyacheslav Benedichuk
 
Upgrade my PaaS
Derek Bingham
 
Azure Messaging Services 2
Azure Riyadh User Group
 
.NET Fest 2019. Alex Pshul. When IoT Meets Serverless
NETFest
 
Ad

More from Tamir Dresher (20)

PPTX
Engineering tools for making smarter decisions .pptx
Tamir Dresher
 
PDF
NET Aspire - NET Conf IL 2024 - Tamir Dresher.pdf
Tamir Dresher
 
PPTX
Tamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher
 
PPTX
Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher
 
PPTX
Tamir Dresher - Async Streams in C#
Tamir Dresher
 
PPTX
Anatomy of a data driven architecture - Tamir Dresher
Tamir Dresher
 
PPTX
Tamir Dresher Clarizen adventures with the wild GC during the holiday season
Tamir Dresher
 
PDF
Debugging tricks you wish you knew Tamir Dresher - Odessa 2019
Tamir Dresher
 
PDF
From zero to hero with the actor model - Tamir Dresher - Odessa 2019
Tamir Dresher
 
PPTX
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher
 
PPTX
Breaking the monolith to microservice with Docker and Kubernetes (k8s)
Tamir Dresher
 
PPTX
.Net december 2017 updates - Tamir Dresher
Tamir Dresher
 
PPTX
Testing time and concurrency Rx
Tamir Dresher
 
PPTX
Building responsive application with Rx - confoo - tamir dresher
Tamir Dresher
 
PPTX
.NET Debugging tricks you wish you knew tamir dresher
Tamir Dresher
 
PPTX
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
PPTX
Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
PPTX
Debugging tricks you wish you knew - Tamir Dresher
Tamir Dresher
 
PPTX
Rx 101 - Tamir Dresher - Copenhagen .NET User Group
Tamir Dresher
 
PPTX
Reactiveness All The Way - SW Architecture 2015 Conference
Tamir Dresher
 
Engineering tools for making smarter decisions .pptx
Tamir Dresher
 
NET Aspire - NET Conf IL 2024 - Tamir Dresher.pdf
Tamir Dresher
 
Tamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher
 
Tamir Dresher - What’s new in ASP.NET Core 6
Tamir Dresher
 
Tamir Dresher - Async Streams in C#
Tamir Dresher
 
Anatomy of a data driven architecture - Tamir Dresher
Tamir Dresher
 
Tamir Dresher Clarizen adventures with the wild GC during the holiday season
Tamir Dresher
 
Debugging tricks you wish you knew Tamir Dresher - Odessa 2019
Tamir Dresher
 
From zero to hero with the actor model - Tamir Dresher - Odessa 2019
Tamir Dresher
 
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher
 
Breaking the monolith to microservice with Docker and Kubernetes (k8s)
Tamir Dresher
 
.Net december 2017 updates - Tamir Dresher
Tamir Dresher
 
Testing time and concurrency Rx
Tamir Dresher
 
Building responsive application with Rx - confoo - tamir dresher
Tamir Dresher
 
.NET Debugging tricks you wish you knew tamir dresher
Tamir Dresher
 
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
Debugging tricks you wish you knew - Tamir Dresher
Tamir Dresher
 
Rx 101 - Tamir Dresher - Copenhagen .NET User Group
Tamir Dresher
 
Reactiveness All The Way - SW Architecture 2015 Conference
Tamir Dresher
 
Ad

Recently uploaded (20)

PDF
How Attendance Management Software is Revolutionizing Education.pdf
Pikmykid
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PDF
Notification System for Construction Logistics Application
Safe Software
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
How Odoo ERP Enhances Operational Visibility Across Your Organization.pptx
pintadoxavier667
 
PPT
24-BuildingGUIs Complete Materials in Java.ppt
javidmiakhil63
 
PDF
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
 
PPTX
leaf desease detection using machine learning.pptx
kdjeevan35
 
PDF
Australian Enterprises Need Project Service Automation
Navision India
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
Instantiations Company Update (ESUG 2025)
ESUG
 
PPTX
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
PDF
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
PPTX
API DOCUMENTATION | API INTEGRATION PLATFORM
philipnathen82
 
PDF
Optimizing Tiered Storage for Low-Latency Real-Time Analytics at AI Scale
Alluxio, Inc.
 
PDF
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
How Attendance Management Software is Revolutionizing Education.pdf
Pikmykid
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
Notification System for Construction Logistics Application
Safe Software
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
How Odoo ERP Enhances Operational Visibility Across Your Organization.pptx
pintadoxavier667
 
24-BuildingGUIs Complete Materials in Java.ppt
javidmiakhil63
 
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
 
leaf desease detection using machine learning.pptx
kdjeevan35
 
Australian Enterprises Need Project Service Automation
Navision India
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Instantiations Company Update (ESUG 2025)
ESUG
 
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
API DOCUMENTATION | API INTEGRATION PLATFORM
philipnathen82
 
Optimizing Tiered Storage for Low-Latency Real-Time Analytics at AI Scale
Alluxio, Inc.
 
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 

Azure Cloud Patterns

  • 2. About Me • Software architect, consultant and instructor • Software Engineering Lecturer @ Ruppin Academic Center • Technology addict • .NET and Native Windows Programming @tamir_dresher [email protected] http://www.TamirDresher.com.
  • 4. Agenda • What are Cloud Patterns • Queue Centric • Poison Messages • Retry Logic • Circuit Breaker • Cache Aside
  • 5. What are Cloud Patterns • Architectural Patterns: “A design pattern in architecture and  computer science is a formal way of  documenting a solution to a design problem  in a particular field of expertise” (http://en.wikipedia.org/wiki/Architectural_patterns)
  • 7. DevGeek Coffee Shop • DevGeek Coffee is a well known and established coffee shop • In business for 20 years • Lately, with the increasing competition, sales are dropping • Lets Help!
  • 8. DevGeek Coffee Shop - Operations coffee
  • 9. DevGeek Coffee Shop - Operations coffee#!$@
  • 10. What does this has to do with software? • Cashier == Server • Basically, this is a scalability issue • Running in the cloud (potentially) makes scaling problem appear faster
  • 11. Scale Up • Add More Resources to a Node • Faster cashier – Better CPU to the server – More Memory • Faster Coffee machine – Use a better algorithm/service
  • 12. Everything has a limit MoneyMoney CPUCPU MEMMEMBANDWIDTH BANDWIDTH StorageStorage
  • 13. Scale out • Add More Nodes – More Cashiers • Load Distribution – Round Robin – Performance – Other (location, expertise, etc)
  • 15. Meet The Problem 2 DevGeek Coffee Shop
  • 16. DevGeek Coffee Shop – The clients complaints • Long standing • Sometimes orders gets lost • Sometimes the line is so long that the workers close the doors
  • 17. DevGeek Coffee Shop – Latency and throughput • Latency is a time interval between the stimulation and response – Time between ordering and receiving the coffee • Throughput is the number of requests that can be served per unit time
  • 18. DevGeek Coffee Shop – Aroma model coffee .
  • 19. Message Centric Web Sites worker role : : worker roleweb role
  • 20. Message Centric – Load Leveling : : Request Received at variable rate Messages Processed at consistent rate
  • 21. Message Centric – Resilency : : X X
  • 22. Message Centric – Delayed Processing : :
  • 23. Azure Queuing Options • Azure Storage Queues – Simple, Reliable, Persistent Queue – Max 200TB and 7 days TTL per message • Azure Service Bus – Broader capabilities: publish/subscribe, remoting, integration patterns – Max 80GB and unlimited TTL per message http://msdn.microsoft.com/en-us/library/hh767287.aspx
  • 24. Azure Service Bus – Queueing
  • 25. Service Bus Messaging - Queue • Two parts: 1. key/value properties 2. binary message body. • Example: a sales application sends message properties:  • *Seller="Ava"   • *Amount=10000. • body : The sale's signed contract scanned image
  • 27. C2 2 1 2 1 1 1 1 1 Removing Poison Messages 1 1 1 1 2 1 2 1 334 0 4 0 Producers Consumers 3 0 3 0 2. GetMessage(Q, 30 s)  msg 2 1. GetMessage(Q, 30 s)  msg 1 1 1 1 1 2 1 2 1 1 0 1 0 2 0 2 0 P2 P1 C1
  • 28. C2 P2 P1 C1 Removing Poison Messages 34 0 4 0 Producers Consumers 1 1 1 1 2 1 2 1 2. GetMessage(Q, 30 s)  msg 2 3. C2 consumed msg 2 4. DeleteMessage(Q, msg 2) 7. GetMessage(Q, 30 s)  msg 1 1. GetMessage(Q, 30 s)  msg 1 5. C1 crashed 1 1 1 1 2 1 2 1 6. msg1 visible 30 s after Dequeue3 0 3 0 1 2 1 2 1 1 1 1 1 2 1 2
  • 29. C2 P2 P1 C1 Removing Poison Messages 34 0 4 0 Producers Consumers 1 2 1 2 2. Dequeue(Q, 30 sec)  msg 2 3. C2 consumed msg 2 4. Delete(Q, msg 2) 7. Dequeue(Q, 30 sec)  msg 1 8. C2 crashed 1. Dequeue(Q, 30 sec)  msg 1 5. C1 crashed 10. C1 restarted 11. Dequeue(Q, 30 sec)  msg 1 12. DeliveryCount > 2 13. msg1.DeadLetter 1 2 1 2 6. msg1 visible 30s after Dequeue 9. msg1 visible 30s after Dequeue 3 0 3 0 1 3 1 3 1 2 1 2 1 3 1 3
  • 30. Service Bus Messaging – Dead letters • the name of the sub-queue is [queueName]/ $DeadLetterQueue • The path can be obtained using the FormatDeadLetterPath method of the QueueClient • Can be consumed by any other consumer and check the messages, log them etc.
  • 31. Priority Queue • The queue may hold message with different priorities (3-High, 1-Low) Web Sites worker role : : worker roleweb role :
  • 34. Meet The Problem 3 DevGeek Coffee Shop
  • 35. DevGeek Coffee Shop – The clients complaints 1. Sometimes the soy milk ran out 2. the barista calls to the storeroom 3. The line is busy 4. The barista move to next order 5. Customer receive an order cancellation
  • 36. Transient Faults • “Transient fault is a fault that is no longer present if power is disconnected for a short time and then restored.” (http ://en.wikipedia.org/wiki/Transient_fault#Transient_fault) • Many faults in connectivity to cloud are transient by nature • Commonly occur when connecting to service or database
  • 37. Retry Pattern • If at first you don’t succeed, try try again (William Edward Hickson) • Retry Logic – Linear – every fixed amount of time – Exponential – if the server is heavy-used (throttling) we don’t want to flood it immediate….1 sec….5 seconds….etc. – Other
  • 38. Operation With Basic Retry     int currentRetry = 0;     while (currentRetry < MaxRetries)     {         try         {             // Calling external service.             await TransientOperationAsync();         }         catch (Exception ex)         {             currentRetry++;               // Check if the exception thrown was a transient exception             if (!IsTransient(ex))             {                 // If this is not a transient error                  // or we should not retry re-throw the exception.                  throw;             }         }          await Task.Delay(TimeBetweenRetries);     }
  • 39. Retry Pattern – Solutions • Azure Storage IRetryPolicy • Azure Service Bus RetryPolicy IRetryPolicy noRetryPolicy = new NoRetry(); BlobRequestOptions requestOptions = new BlobRequestOptions() { RetryPolicy = noRetryPolicy, }; MessagingFactory factory = MessagingFactory.Create(); factory.RetryPolicy = RetryExponential.Default; factory.RetryPolicy = RetryPolicy.NoRetry;
  • 40. The Transient Fault Handling Application Block var retryPolicy = new Incremental(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)); retryPolicy.Retrying += (sender, args) => { Trace.WriteLine(args.LastException, "Information"); }; try { retryPolicy.ExecuteAction(() => { TranisentErrorOperation(); }); } catch (Exception) { // All the retries failed. } http://msdn.microsoft.com/en-us/library/hh680934(v=pandp.50).aspx
  • 42. Retry Logic – Not Always Not all The time • Baristas keeps retrying/failing – Time Consuming • Maybe we can call someone else? • The remote service still might get flooded • If a failure is not transient, we wish that next attempts fail immediately
  • 43. Circuit Breaker • Circuit Breaker pattern prevent repeatedly trying to execute an operation that is likely to fail • continue without waiting for the fault to be rectified • Prevents wasting valuable resources because of the wait
  • 44. Circuit Breaker • The Circuit Breaker is a proxy • Monitor the number of recent failures • Decide if to proceed or do something else – Throw exception – Try different destination
  • 45. Circuit Breaker States Closed Open Success Fail [threshold reached] Half Open Retry Timeout Fail Success Fail [under threshold]
  • 47. Deja vu • We fetch the same data • We run the same calculation • We query the same service
  • 49. Azure Caching • Azure Managed Cache • Azure Redis Cache • In-Role Cache
  • 50. In Role Cache – co-located
  • 51. In Role Cache - Dedicated
  • 53. Summery • What are Cloud Patterns • Queue Centric • Poison Messages • Retry Logic • Circuit Breaker • Cache Aside
  • 54. References • P&P Cloud Design Patterns - http://msdn.microsoft.com/en-us/library/dn568099.aspx • http://cloudpatterns.org/ • Cloud Architecture Patterns
  • 56. Images References 1. http://en.wikipedia.org/wiki/List_of_cloud_types 2. http://www.freedigitalphotos.net/images/Emotions_g96- Arms_Up_Character_Shows_Shock_And_Surprise_p142355.html 3. http://www.freedigitalphotos.net/images/Hot_drinks_g184- Coffee_In_White_Cup_p96634.html