SlideShare a Scribd company logo
Finding Patterns
in the
Clouds
Steve “ardalis” Smith
@ardalis | steve@ardalis.com
ardalis.com | weeklydevtips.com
Design Patterns for Cloud-
Native Applications
Please Rate in the App
• AttendeeHub
@ardalis | Finding Patterns in the Clouds
More Resources
• Podcast
WeeklyDevTips.com
• Group Mentoring Program
DevBetter.com
• Free Microsoft eBooks
ardalis.com/architecture-ebook
ardalis.com/cloud-native-book
@ardalis | Finding Patterns in the Clouds
Let’s take a trip back to the
beginning of today’s web…
@ardalis | Finding Patterns in the Clouds
Finding Patterns in the Clouds - Cloud Design Patterns
(not that far)
A Simpler Time
“Just” ~20 years ago…
Compaq AlphaServer DS20 circa 1999
@ardalis | Finding Patterns in the Clouds
A Simpler Time
“Just” 20 years ago…
One Web Server To Rule Them All
Client Machine Server
Request
Response
App
Data
(and one Webmaster to run it all – the original Full Stack Developer™)
@ardalis | Finding Patterns in the Clouds
NCSA Mosaic
One Web Server To Rule Them All
Client Machine Server
Request
Response
Report Card: One Server To Rule Them All
@ardalis | Finding Patterns in the Clouds
Availability
Data Management
Design and Implementation
Messaging Security
Management and Monitoring
Resiliency
Performance and Scalability
Web App
Considerations and Challenges
@ardalis | Finding Patterns in the Clouds
Cloud-Hosted Web App
Considerations and Challenges
@ardalis | Finding Patterns in the Clouds
Availability
How often is the system or service up?
Often expressed as a percentage.
99.99% uptime = 1 minute of downtime per week
99.999% uptime = 26 seconds of downtime per month
@ardalis | Finding Patterns in the Clouds
Data
Management
Many more options than in traditional-hosted
single-database apps
Distributed data
Consistency
Synchronization
@ardalis | Finding Patterns in the Clouds
Design and
Implementation
Consistency is key
Consider factors like
• Maintenance ease
• Administration
• Development
• Diagnostics
• Cost
@ardalis | Finding Patterns in the Clouds
Messaging
How do subsystems communicate?
Direct, synchronous calls?
Asynchronous messaging?
Each option presents challenges.
@ardalis | Finding Patterns in the Clouds
Management
and Monitoring
No direct server access to PaaS resources
means other tools are critical.
Cloud resources are more like cattle herds
than pets.
@ardalis | Finding Patterns in the Clouds
Performance
and Scalability
How responsive is the system to requests?
How does this responsiveness change with
increased load?
Scaling up
Scaling out
@ardalis | Finding Patterns in the Clouds
Resiliency
Can the system gracefully (and automatically)
recover from errors or failures?
Detect failures and replace resources
automatically
@ardalis | Finding Patterns in the Clouds
Security
Protect from attacks
Guard sensitive data
Restrict access to approved users
@ardalis | Finding Patterns in the Clouds
One Machine To Rule Them All
Client Machine Server
Request
Response
App
Data
@ardalis | Finding Patterns in the Clouds
Report Card: One Server To Rule Them All
🙁
🙂
🙂
🙂
🙂
🙂 but also 🙁
😐
😐
@ardalis | Finding Patterns in the Clouds
Demand Grows
🙁 Vertical Scaling is
Maxed Out
🙁 Performance is
suffering at times
Remedy:
Move Database to a
separate server
🙂 Performance
improves
Current Assessment:
@ardalis | Finding Patterns in the Clouds
1 Web, 1 DB Server
Client Machine Web Server
Request
Response
App Data
DB Server
@ardalis | Finding Patterns in the Clouds
Parts of the
App are SLOW
🙁 Vertical Scaling is
Maxed Out (both
servers) – or at least
there’s no budget for
more right now
🙂 Data has been
optimized with indexes,
etc. No more gains to be
had here.
🙁 Some queries just
hammer the database,
take time, and impact
other queries.
Current Assessment:
@ardalis | Finding Patterns in the Clouds
Cache Aside Pattern
@ardalis | Finding Patterns in the Clouds
Read-Through Strategy
@ardalis | Finding Patterns in the Clouds
Write-Through Strategy
Data
1. Update the data store 2. Invalidate (or update) its
cache entry
$123
@ardalis | Finding Patterns in the Clouds
Another option is to use a very short cache duration, something I refer to as micro-caching
Add Simple Memory Caching
Client Machine Web Server
Request
Response
App Data
DB Server
Cache
@ardalis | Finding Patterns in the Clouds
There are only 2 hard things in Computer Science
0. Cache Invalidation
1. Naming Things
2. Off-by-One Errors
@ardalis | Finding Patterns in the Clouds
Speaking of Naming Things…
• Use a standard way to generate a cache keys for given scenarios
• Avoid hard-coding keys, especially as local method literals
• Many caching patterns require access to keys from different parts of
your applications (including read vs. write operations)
@ardalis | Finding Patterns in the Clouds
🙂 Performance is
usually (much) better
🙁 Some users still
complain of delays due
to cache misses
🙁 Keeping Cache
up to date is a new
challenge
🙁 Customers may
now see stale data
New Problems…
🙁 New monitoring
required for cache
🙁 New tools to clear
or update cache
required
Hmm, that’s a lot of 🙁
Demand Grows
Time to Scale Out!
Simple Web Farm
Client Machine
Web Server
Request
Response
App
Data
DB Server
Cache
Load Balancer
Web Server
App
Cache
@ardalis | Finding Patterns in the Clouds
🙂Performance and
Scalability improved
🙁 Some users still
complain due to
cache misses
😧 Keeping Multiple
Caches up to date is
a big challenge (in
this model)
New Behavior…
🙁New monitoring
and tools required
for load balancer
🙁 More servers to
manage
🙂 Web servers can
be updated without
taking down the
whole system
@ardalis | Finding Patterns in the Clouds
Embrace the
Cloud!
@ardalis | Finding Patterns in the Clouds
The Cloud (xkcd.com/908)
@ardalis | Finding Patterns in the Clouds
Simple Cloud Architecture
Client Machine
Request
Response
Load Balancer
App Service
Instances
Azure Cache /
Redis Instance
Azure SQL
Database
@ardalis | Finding Patterns in the Clouds
🙂 Scalability
improved
🙁 Some users still
complain due to
cache misses
(consider priming
the cache)
🙂 Cache
synchronization easier
New Behavior…
🙂 No more servers
to manage
🙂 Monitoring tools
built-in to platform
🙂 Web instances
easily managed
without downtime
That ratio of 🙂 to 🙁 is a lot better…@ardalis | Finding Patterns in the Clouds
“Let’s build more of these apps”
@ardalis | Finding Patterns in the Clouds
More Apps
Client Machine
Request
Response
Load Balancer
App Service
Instances
Azure Cache /
Redis Instance
Azure SQL
Database
@ardalis | Finding Patterns in the Clouds
More Apps
App Service
Instances
Azure Cache /
Redis Instance
Azure SQL
Database
App A
App Service
Instances
App B
App Service
Instances
App C
Shared Resources
Everything’s Great! Except…
Vendor lock-in
Shared database hurts
Shared resources (e.g. data schema) limit app developer agility
We’ll address these in a moment but first…
@ardalis | Finding Patterns in the Clouds
“Don’t forget auth!”
@ardalis | Finding Patterns in the Clouds
Authentication and Identity
These apps require:
• Single Sign-on
• Security – protection from unauthorized use
• This was surely built into the apps before this point, but the pain
becomes apparent now
@ardalis | Finding Patterns in the Clouds
Simple Database Managed Identity
App Service
Instances
Azure Cache /
Redis Instance
Azure SQL
Database
App A
App Service
Instances
App B
App Service
Instances
App C
Identity
Tables/Data
Username
Password
Login
Username
Password
Login
Username
Password
Login
YOU get a login screen, and YOU get a login screen
Federated Identity Pattern
@ardalis | Finding Patterns in the Clouds
Finding Patterns in the Clouds - Cloud Design Patterns
Redis
Cache
Azure
SQL
App A
Redis
cache
Azure
SQL
App B
Redis
cache
Azure
SQL
App C
Identity
Microservice
Leveraging Containers and Federated Identity
Azure
SQL
Client Machine
1. Authenticate
2. Get Secure Token
3. Present Token
Note: Vendor lock-in mitigated by containers
“What about data sync?”
@ardalis | Finding Patterns in the Clouds
Redis
Cache
Azure
SQL
App A
Redis
cache
Azure
SQL
App B
Redis
cache
Azure
SQL
App C
Identity
Microservice
Implementing a Message/Event Bus
Azure
SQL
@ardalis | Finding Patterns in the Clouds
Moving from Apps to Microservices
• Apps are very coarse-grained to deploy, scale
• Common functionality duplicated between apps
• Stable parts of apps disrupted by deployment of unstable bits
• Decompose apps into small, independent, cohesive microservices
@ardalis | Finding Patterns in the Clouds
App A – An eCommerce Site
Redis
Cache
Azure
SQL
App A
Client apps
Mobile
app
Web
app
@ardalis | Finding Patterns in the Clouds
Microservice 2
Microservice 1
container
container
Web API
Web API
Microservice 3
container
Web API
Client apps
Microservices
Split into Microservices
Call each as appropriate from clients
Mobile
app
Web
app
Security Concerns
• Client apps may not need every
microservice feature
• Microservices may have multiple
clients; shouldn’t need to know
security rules of every one
• Should limit feature surface area
specific to client needs
@ardalis | Finding Patterns in the Clouds
API Gateway Pattern
@ardalis | Finding Patterns in the Clouds
Using a custom API Gateway Service
Microservice 2
Microservice 1
Client WebApp MVC
container
container
Web API
Web API
ASP.NET Core MVC
container
Microservice 3
container
Web API
Client SPA Web app
JavaScript
Client mobile app
API Gateway
ASP.NET Core
Web API
container
Back end
Traditional Web app
Browser
HTML
HTML
JSON
JSON
API Gateway with Azure API Management
Architecture
Client WebApp MVC
ASP.NET Core MVC
container
Client SPA Web app
JavaScript
Client mobile app
Developer portal
API Gateway
Publisher portal
Azure API Management
Microservice 2
Microservice 1
container
container
Web API
Web API
Microservice 3
container
Web API
Back end
Accessing Secure Files
@ardalis | Finding Patterns in the Clouds
New Problem – Secure File Access
• Apps control access to media files based on authorized user
• Simple approach of a dumb CDN doesn’t protect actual media URLs
from being accessed by anyone
• Current solution: Web App authenticates user, accesses the file, and
streams it to the end user
@ardalis | Finding Patterns in the Clouds
Secure Media File Access
Client Machine
Request
Response
Web App
Request
Response
File/BLOB Store
(not publicly
accessible)
@ardalis | Finding Patterns in the Clouds
Concerns
🙁 Load on web app
higher than necessary
🙁 Cost! 💰 May be
paying extra to move
files in/out of web
app
🙁 Greater chance
of downtime with
web app and file
store both required
to stream file
@ardalis | Finding Patterns in the Clouds
Valet Key
• Provide direct access to media
files using an access token
• Azure supports Shared Access
Signatures (SAS) for this purpose
• File transfers occur directly
between file store and client
@ardalis | Finding Patterns in the Clouds
Remote Resources
@ardalis | Finding Patterns in the Clouds
“I want fast, reliable, always-on services!”
@ardalis | Finding Patterns in the Clouds
Retry Pattern
First attempt failed
• Is it likely to be a transient problem? If not, give up.
• Immediately try again (maybe it was just a fluke)
• (wait)
• Try again
• (wait longer)
• Try again
• Give up.
@ardalis | Finding Patterns in the Clouds
Retries can overload downstream service
• Imagine typical load is 10 requests per second.
• With a typical “try 3 times then fail” strategy, when the service comes
up it’s immediately seeing 30 requests per second of load!
• Can result in longer time to respond and creation of more resources
than necessary (more hosting $$$)
• Don’t DOS (denial of service) yourself!
@ardalis | Finding Patterns in the Clouds
Circuit-Breaker Pattern
3 States
• Closed (working)
• Open (not working)
• Half-Open (throttled)
Circuit Breaker States
@ardalis | Finding Patterns in the Clouds
Closed
Open
When failCount > threshold, Open
Half-Open
After [timeout], go to Half-Open
Still not responding…
Reset failCount to zero and Close
Retry on failure; increment failCount
Consider a tool like Polly
@ardalis | Finding Patterns in the Clouds
Bonus Microservice Anti-Pattern:
Reach-In Reporting
Approach 1
• Microservices access reporting
data directly
• Introduces coupling
• Reduces microservice
independence
• Bypasses microservice logic
Source: Microservices AntiPatterns and Pitfalls by Mark Richards - https://oreil.ly/2J4r67x
Bonus Microservice Anti-Pattern:
Reach-In Reporting
Approach 2
• Reporting app hits
microservices directly
• Poor performance
• Data may be too large for
HTTP
• Difficult to perform complex
queries
Source: Microservices AntiPatterns and Pitfalls by Mark Richards - https://oreil.ly/2J4r67x
Bonus Microservice Anti-Pattern:
Reach-In Reporting
Approach 3
• Batch job updates reporting db
from microservice dbs
• Same coupling as approach 1.
Changes to microservice db
schemas break batch data job.
Source: Microservices AntiPatterns and Pitfalls by Mark Richards - https://oreil.ly/2J4r67x
Bonus Microservice Anti-Pattern:
Reach-In Reporting
Solution
• Async event publication
• Encapsulation and
independence of microservices
is preserved
• Performance is usually
acceptable
Source: Microservices AntiPatterns and Pitfalls by Mark Richards - https://oreil.ly/2J4r67x
Key Takeaways
• Cloud architecture abstracts away servers
• Cache Aside pattern is great for performance improvements
• Containers offer improved deployment and scaling options with less
vendor lock-in
• Microservices offer finer-grained control over app functionality
• Federated Identity improves security and user experience
• API Gateways help secure collections of services
• Valet key provides cheaper, faster access to secure media
• Consider Retry but you may need a Circuit-Breaker
• Avoid the Reach In Reporting anti-pattern for your microservices
@ardalis | Finding Patterns in the Clouds
More Cloud Design Patterns
https://bit.ly/1T8q2w8
@ardalis | Finding Patterns in the Clouds
Thank You!
• Contact me!
twitter.com/ardalis
steve@ardalis.com
• Podcast
WeeklyDevTips.com
• Group Mentoring Program
DevBetter.com
• Free Microsoft eBooks
ardalis.com/architecture-ebook
ardalis.com/cloud-native-book

More Related Content

What's hot (18)

PDF
Resilience Engineering: A field of study, a community, and some perspective s...
John Allspaw
 
PDF
Scaling Indexing and Replication in Jira Data Center Apps
Atlassian
 
PDF
Future of Java
Eberhard Wolff
 
PDF
The Modern Java Web Developer - Denver JUG 2013
Matt Raible
 
PDF
What's Missing? Microservices Meetup at Cisco
Adrian Cockcroft
 
PDF
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
Vadym Kazulkin
 
PDF
Microservices for java architects schamburg-2015-05-19
Derek Ashmore
 
PDF
BPMN, BPEL, ESB or maybe Java? What should I use to implement my project?
Guido Schmutz
 
PDF
Writing less code with Serverless on AWS at OOP 2022
Vadym Kazulkin
 
PDF
Six simple steps to unit testing happiness
Steven Feuerstein
 
PDF
Arquillian & Citrus
christophd
 
PDF
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
Edureka!
 
PPTX
Cloud and agile software projects: Overview and Benefits
Guillaume Berche
 
PDF
An Introduction to Dependency Injection
Adam Stephensen
 
PDF
An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...
Abhay Bhargav
 
PDF
AskTOM Office Hours - Dynamic SQL in PL/SQL
Steven Feuerstein
 
PPTX
Load testing with Visual Studio and Azure - Andrew Siemer
Andrew Siemer
 
PDF
Integration Testing on Steroids: Run Your Tests on the Real Things
Atlassian
 
Resilience Engineering: A field of study, a community, and some perspective s...
John Allspaw
 
Scaling Indexing and Replication in Jira Data Center Apps
Atlassian
 
Future of Java
Eberhard Wolff
 
The Modern Java Web Developer - Denver JUG 2013
Matt Raible
 
What's Missing? Microservices Meetup at Cisco
Adrian Cockcroft
 
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
Vadym Kazulkin
 
Microservices for java architects schamburg-2015-05-19
Derek Ashmore
 
BPMN, BPEL, ESB or maybe Java? What should I use to implement my project?
Guido Schmutz
 
Writing less code with Serverless on AWS at OOP 2022
Vadym Kazulkin
 
Six simple steps to unit testing happiness
Steven Feuerstein
 
Arquillian & Citrus
christophd
 
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
Edureka!
 
Cloud and agile software projects: Overview and Benefits
Guillaume Berche
 
An Introduction to Dependency Injection
Adam Stephensen
 
An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...
Abhay Bhargav
 
AskTOM Office Hours - Dynamic SQL in PL/SQL
Steven Feuerstein
 
Load testing with Visual Studio and Azure - Andrew Siemer
Andrew Siemer
 
Integration Testing on Steroids: Run Your Tests on the Real Things
Atlassian
 

Similar to Finding Patterns in the Clouds - Cloud Design Patterns (20)

PPTX
Cloud First Architecture
Cameron Vetter
 
PDF
Azure and cloud design patterns
Venkatesh Narayanan
 
PPTX
Applicare patterns di sviluppo con Azure
Marco Parenzan
 
PDF
Cloud Design Patterns
Carlos Mendible
 
PDF
Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...
David J Rosenthal
 
PPTX
Building azure applications ireland
Michael Meagher
 
PPTX
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Vikas Sahni
 
PPTX
Apply Coding Patterns in Azure
Marco Parenzan
 
PPTX
Azure presentation nnug dec 2010
Ethos Technologies
 
PPTX
Azure architecture design patterns - proven solutions to common challenges
Ivo Andreev
 
PDF
Computational Patterns of the Cloud
C4Media
 
PPTX
Cloud - Azure – an introduction
Saravanan Subburayal
 
PPTX
Design Pattern that every cloud developer must know
Shahriar Iqbal Chowdhury
 
PDF
Cloud Design Patterns Book from Microsoft
Kesavan Munuswamy
 
PPTX
Microsoft Azure Cloud Basics Tutorial
IIMSE Edu
 
PPTX
8 cloud design patterns you ought to know - Update Conference 2018
Taswar Bhatti
 
PDF
Xebia Knowledge Exchange (jan 2011) - Trends in Enterprise Applications Archi...
Michaël Figuière
 
PDF
Architecting Cloud Applications - the essential checklist
Object Consulting
 
PDF
MS Cloud Design Patterns Infographic 2015
James Tramel
 
PDF
Ms cloud design patterns infographic 2015
Kesavan Munuswamy
 
Cloud First Architecture
Cameron Vetter
 
Azure and cloud design patterns
Venkatesh Narayanan
 
Applicare patterns di sviluppo con Azure
Marco Parenzan
 
Cloud Design Patterns
Carlos Mendible
 
Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...
David J Rosenthal
 
Building azure applications ireland
Michael Meagher
 
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Vikas Sahni
 
Apply Coding Patterns in Azure
Marco Parenzan
 
Azure presentation nnug dec 2010
Ethos Technologies
 
Azure architecture design patterns - proven solutions to common challenges
Ivo Andreev
 
Computational Patterns of the Cloud
C4Media
 
Cloud - Azure – an introduction
Saravanan Subburayal
 
Design Pattern that every cloud developer must know
Shahriar Iqbal Chowdhury
 
Cloud Design Patterns Book from Microsoft
Kesavan Munuswamy
 
Microsoft Azure Cloud Basics Tutorial
IIMSE Edu
 
8 cloud design patterns you ought to know - Update Conference 2018
Taswar Bhatti
 
Xebia Knowledge Exchange (jan 2011) - Trends in Enterprise Applications Archi...
Michaël Figuière
 
Architecting Cloud Applications - the essential checklist
Object Consulting
 
MS Cloud Design Patterns Infographic 2015
James Tramel
 
Ms cloud design patterns infographic 2015
Kesavan Munuswamy
 
Ad

More from Steven Smith (20)

PPTX
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Steven Smith
 
PPTX
Introducing Domain Driven Design - codemash
Steven Smith
 
PPTX
Introducing ASP.NET Core 2.0
Steven Smith
 
PPTX
Decoupling with Domain Events
Steven Smith
 
PPTX
Improving the Quality of Existing Software
Steven Smith
 
PPTX
Improving the Quality of Existing Software
Steven Smith
 
PPTX
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Steven Smith
 
PPTX
Improving the Quality of Existing Software - DevIntersection April 2016
Steven Smith
 
PPTX
Breaking Dependencies to Allow Unit Testing
Steven Smith
 
PPTX
Improving the Quality of Existing Software
Steven Smith
 
PPTX
A Whirldwind Tour of ASP.NET 5
Steven Smith
 
PPTX
Domain events
Steven Smith
 
PPTX
My Iraq Experience
Steven Smith
 
PDF
Domain-Driven Design with ASP.NET MVC
Steven Smith
 
PDF
Breaking Dependencies to Allow Unit Testing
Steven Smith
 
PPTX
Improving The Quality of Existing Software
Steven Smith
 
PPTX
Refactoring with SOLID Principles (FalafelCon 2013)
Steven Smith
 
PPTX
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Steven Smith
 
PPTX
Refactoring with SOLID - Telerik India DevCon 2013
Steven Smith
 
PPTX
Refactoring Applications using SOLID Principles
Steven Smith
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Steven Smith
 
Introducing Domain Driven Design - codemash
Steven Smith
 
Introducing ASP.NET Core 2.0
Steven Smith
 
Decoupling with Domain Events
Steven Smith
 
Improving the Quality of Existing Software
Steven Smith
 
Improving the Quality of Existing Software
Steven Smith
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Steven Smith
 
Improving the Quality of Existing Software - DevIntersection April 2016
Steven Smith
 
Breaking Dependencies to Allow Unit Testing
Steven Smith
 
Improving the Quality of Existing Software
Steven Smith
 
A Whirldwind Tour of ASP.NET 5
Steven Smith
 
Domain events
Steven Smith
 
My Iraq Experience
Steven Smith
 
Domain-Driven Design with ASP.NET MVC
Steven Smith
 
Breaking Dependencies to Allow Unit Testing
Steven Smith
 
Improving The Quality of Existing Software
Steven Smith
 
Refactoring with SOLID Principles (FalafelCon 2013)
Steven Smith
 
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Steven Smith
 
Refactoring with SOLID - Telerik India DevCon 2013
Steven Smith
 
Refactoring Applications using SOLID Principles
Steven Smith
 
Ad

Recently uploaded (20)

PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 

Finding Patterns in the Clouds - Cloud Design Patterns

  • 1. Finding Patterns in the Clouds Steve “ardalis” Smith @ardalis | [email protected] ardalis.com | weeklydevtips.com Design Patterns for Cloud- Native Applications
  • 2. Please Rate in the App • AttendeeHub @ardalis | Finding Patterns in the Clouds
  • 3. More Resources • Podcast WeeklyDevTips.com • Group Mentoring Program DevBetter.com • Free Microsoft eBooks ardalis.com/architecture-ebook ardalis.com/cloud-native-book @ardalis | Finding Patterns in the Clouds
  • 4. Let’s take a trip back to the beginning of today’s web… @ardalis | Finding Patterns in the Clouds
  • 7. A Simpler Time “Just” ~20 years ago… Compaq AlphaServer DS20 circa 1999 @ardalis | Finding Patterns in the Clouds
  • 8. A Simpler Time “Just” 20 years ago…
  • 9. One Web Server To Rule Them All Client Machine Server Request Response App Data (and one Webmaster to run it all – the original Full Stack Developer™) @ardalis | Finding Patterns in the Clouds NCSA Mosaic
  • 10. One Web Server To Rule Them All Client Machine Server Request Response
  • 11. Report Card: One Server To Rule Them All @ardalis | Finding Patterns in the Clouds Availability Data Management Design and Implementation Messaging Security Management and Monitoring Resiliency Performance and Scalability
  • 12. Web App Considerations and Challenges @ardalis | Finding Patterns in the Clouds
  • 13. Cloud-Hosted Web App Considerations and Challenges @ardalis | Finding Patterns in the Clouds
  • 14. Availability How often is the system or service up? Often expressed as a percentage. 99.99% uptime = 1 minute of downtime per week 99.999% uptime = 26 seconds of downtime per month @ardalis | Finding Patterns in the Clouds
  • 15. Data Management Many more options than in traditional-hosted single-database apps Distributed data Consistency Synchronization @ardalis | Finding Patterns in the Clouds
  • 16. Design and Implementation Consistency is key Consider factors like • Maintenance ease • Administration • Development • Diagnostics • Cost @ardalis | Finding Patterns in the Clouds
  • 17. Messaging How do subsystems communicate? Direct, synchronous calls? Asynchronous messaging? Each option presents challenges. @ardalis | Finding Patterns in the Clouds
  • 18. Management and Monitoring No direct server access to PaaS resources means other tools are critical. Cloud resources are more like cattle herds than pets. @ardalis | Finding Patterns in the Clouds
  • 19. Performance and Scalability How responsive is the system to requests? How does this responsiveness change with increased load? Scaling up Scaling out @ardalis | Finding Patterns in the Clouds
  • 20. Resiliency Can the system gracefully (and automatically) recover from errors or failures? Detect failures and replace resources automatically @ardalis | Finding Patterns in the Clouds
  • 21. Security Protect from attacks Guard sensitive data Restrict access to approved users @ardalis | Finding Patterns in the Clouds
  • 22. One Machine To Rule Them All Client Machine Server Request Response App Data @ardalis | Finding Patterns in the Clouds
  • 23. Report Card: One Server To Rule Them All 🙁 🙂 🙂 🙂 🙂 🙂 but also 🙁 😐 😐 @ardalis | Finding Patterns in the Clouds
  • 25. 🙁 Vertical Scaling is Maxed Out 🙁 Performance is suffering at times Remedy: Move Database to a separate server 🙂 Performance improves Current Assessment: @ardalis | Finding Patterns in the Clouds
  • 26. 1 Web, 1 DB Server Client Machine Web Server Request Response App Data DB Server @ardalis | Finding Patterns in the Clouds
  • 27. Parts of the App are SLOW
  • 28. 🙁 Vertical Scaling is Maxed Out (both servers) – or at least there’s no budget for more right now 🙂 Data has been optimized with indexes, etc. No more gains to be had here. 🙁 Some queries just hammer the database, take time, and impact other queries. Current Assessment: @ardalis | Finding Patterns in the Clouds
  • 29. Cache Aside Pattern @ardalis | Finding Patterns in the Clouds
  • 30. Read-Through Strategy @ardalis | Finding Patterns in the Clouds
  • 31. Write-Through Strategy Data 1. Update the data store 2. Invalidate (or update) its cache entry $123 @ardalis | Finding Patterns in the Clouds Another option is to use a very short cache duration, something I refer to as micro-caching
  • 32. Add Simple Memory Caching Client Machine Web Server Request Response App Data DB Server Cache @ardalis | Finding Patterns in the Clouds
  • 33. There are only 2 hard things in Computer Science 0. Cache Invalidation 1. Naming Things 2. Off-by-One Errors @ardalis | Finding Patterns in the Clouds
  • 34. Speaking of Naming Things… • Use a standard way to generate a cache keys for given scenarios • Avoid hard-coding keys, especially as local method literals • Many caching patterns require access to keys from different parts of your applications (including read vs. write operations) @ardalis | Finding Patterns in the Clouds
  • 35. 🙂 Performance is usually (much) better 🙁 Some users still complain of delays due to cache misses 🙁 Keeping Cache up to date is a new challenge 🙁 Customers may now see stale data New Problems… 🙁 New monitoring required for cache 🙁 New tools to clear or update cache required Hmm, that’s a lot of 🙁
  • 38. Simple Web Farm Client Machine Web Server Request Response App Data DB Server Cache Load Balancer Web Server App Cache @ardalis | Finding Patterns in the Clouds
  • 39. 🙂Performance and Scalability improved 🙁 Some users still complain due to cache misses 😧 Keeping Multiple Caches up to date is a big challenge (in this model) New Behavior… 🙁New monitoring and tools required for load balancer 🙁 More servers to manage 🙂 Web servers can be updated without taking down the whole system @ardalis | Finding Patterns in the Clouds
  • 40. Embrace the Cloud! @ardalis | Finding Patterns in the Clouds
  • 41. The Cloud (xkcd.com/908) @ardalis | Finding Patterns in the Clouds
  • 42. Simple Cloud Architecture Client Machine Request Response Load Balancer App Service Instances Azure Cache / Redis Instance Azure SQL Database @ardalis | Finding Patterns in the Clouds
  • 43. 🙂 Scalability improved 🙁 Some users still complain due to cache misses (consider priming the cache) 🙂 Cache synchronization easier New Behavior… 🙂 No more servers to manage 🙂 Monitoring tools built-in to platform 🙂 Web instances easily managed without downtime That ratio of 🙂 to 🙁 is a lot better…@ardalis | Finding Patterns in the Clouds
  • 44. “Let’s build more of these apps” @ardalis | Finding Patterns in the Clouds
  • 45. More Apps Client Machine Request Response Load Balancer App Service Instances Azure Cache / Redis Instance Azure SQL Database @ardalis | Finding Patterns in the Clouds
  • 46. More Apps App Service Instances Azure Cache / Redis Instance Azure SQL Database App A App Service Instances App B App Service Instances App C Shared Resources
  • 47. Everything’s Great! Except… Vendor lock-in Shared database hurts Shared resources (e.g. data schema) limit app developer agility We’ll address these in a moment but first… @ardalis | Finding Patterns in the Clouds
  • 48. “Don’t forget auth!” @ardalis | Finding Patterns in the Clouds
  • 49. Authentication and Identity These apps require: • Single Sign-on • Security – protection from unauthorized use • This was surely built into the apps before this point, but the pain becomes apparent now @ardalis | Finding Patterns in the Clouds
  • 50. Simple Database Managed Identity App Service Instances Azure Cache / Redis Instance Azure SQL Database App A App Service Instances App B App Service Instances App C Identity Tables/Data Username Password Login Username Password Login Username Password Login YOU get a login screen, and YOU get a login screen
  • 51. Federated Identity Pattern @ardalis | Finding Patterns in the Clouds
  • 53. Redis Cache Azure SQL App A Redis cache Azure SQL App B Redis cache Azure SQL App C Identity Microservice Leveraging Containers and Federated Identity Azure SQL Client Machine 1. Authenticate 2. Get Secure Token 3. Present Token Note: Vendor lock-in mitigated by containers
  • 54. “What about data sync?” @ardalis | Finding Patterns in the Clouds
  • 55. Redis Cache Azure SQL App A Redis cache Azure SQL App B Redis cache Azure SQL App C Identity Microservice Implementing a Message/Event Bus Azure SQL @ardalis | Finding Patterns in the Clouds
  • 56. Moving from Apps to Microservices • Apps are very coarse-grained to deploy, scale • Common functionality duplicated between apps • Stable parts of apps disrupted by deployment of unstable bits • Decompose apps into small, independent, cohesive microservices @ardalis | Finding Patterns in the Clouds
  • 57. App A – An eCommerce Site Redis Cache Azure SQL App A Client apps Mobile app Web app @ardalis | Finding Patterns in the Clouds
  • 58. Microservice 2 Microservice 1 container container Web API Web API Microservice 3 container Web API Client apps Microservices Split into Microservices Call each as appropriate from clients Mobile app Web app
  • 59. Security Concerns • Client apps may not need every microservice feature • Microservices may have multiple clients; shouldn’t need to know security rules of every one • Should limit feature surface area specific to client needs @ardalis | Finding Patterns in the Clouds
  • 60. API Gateway Pattern @ardalis | Finding Patterns in the Clouds
  • 61. Using a custom API Gateway Service Microservice 2 Microservice 1 Client WebApp MVC container container Web API Web API ASP.NET Core MVC container Microservice 3 container Web API Client SPA Web app JavaScript Client mobile app API Gateway ASP.NET Core Web API container Back end Traditional Web app Browser HTML HTML JSON JSON
  • 62. API Gateway with Azure API Management Architecture Client WebApp MVC ASP.NET Core MVC container Client SPA Web app JavaScript Client mobile app Developer portal API Gateway Publisher portal Azure API Management Microservice 2 Microservice 1 container container Web API Web API Microservice 3 container Web API Back end
  • 63. Accessing Secure Files @ardalis | Finding Patterns in the Clouds
  • 64. New Problem – Secure File Access • Apps control access to media files based on authorized user • Simple approach of a dumb CDN doesn’t protect actual media URLs from being accessed by anyone • Current solution: Web App authenticates user, accesses the file, and streams it to the end user @ardalis | Finding Patterns in the Clouds
  • 65. Secure Media File Access Client Machine Request Response Web App Request Response File/BLOB Store (not publicly accessible) @ardalis | Finding Patterns in the Clouds
  • 66. Concerns 🙁 Load on web app higher than necessary 🙁 Cost! 💰 May be paying extra to move files in/out of web app 🙁 Greater chance of downtime with web app and file store both required to stream file @ardalis | Finding Patterns in the Clouds
  • 67. Valet Key • Provide direct access to media files using an access token • Azure supports Shared Access Signatures (SAS) for this purpose • File transfers occur directly between file store and client @ardalis | Finding Patterns in the Clouds
  • 68. Remote Resources @ardalis | Finding Patterns in the Clouds
  • 69. “I want fast, reliable, always-on services!” @ardalis | Finding Patterns in the Clouds
  • 70. Retry Pattern First attempt failed • Is it likely to be a transient problem? If not, give up. • Immediately try again (maybe it was just a fluke) • (wait) • Try again • (wait longer) • Try again • Give up. @ardalis | Finding Patterns in the Clouds
  • 71. Retries can overload downstream service • Imagine typical load is 10 requests per second. • With a typical “try 3 times then fail” strategy, when the service comes up it’s immediately seeing 30 requests per second of load! • Can result in longer time to respond and creation of more resources than necessary (more hosting $$$) • Don’t DOS (denial of service) yourself! @ardalis | Finding Patterns in the Clouds
  • 72. Circuit-Breaker Pattern 3 States • Closed (working) • Open (not working) • Half-Open (throttled)
  • 73. Circuit Breaker States @ardalis | Finding Patterns in the Clouds Closed Open When failCount > threshold, Open Half-Open After [timeout], go to Half-Open Still not responding… Reset failCount to zero and Close Retry on failure; increment failCount
  • 74. Consider a tool like Polly @ardalis | Finding Patterns in the Clouds
  • 75. Bonus Microservice Anti-Pattern: Reach-In Reporting Approach 1 • Microservices access reporting data directly • Introduces coupling • Reduces microservice independence • Bypasses microservice logic Source: Microservices AntiPatterns and Pitfalls by Mark Richards - https://oreil.ly/2J4r67x
  • 76. Bonus Microservice Anti-Pattern: Reach-In Reporting Approach 2 • Reporting app hits microservices directly • Poor performance • Data may be too large for HTTP • Difficult to perform complex queries Source: Microservices AntiPatterns and Pitfalls by Mark Richards - https://oreil.ly/2J4r67x
  • 77. Bonus Microservice Anti-Pattern: Reach-In Reporting Approach 3 • Batch job updates reporting db from microservice dbs • Same coupling as approach 1. Changes to microservice db schemas break batch data job. Source: Microservices AntiPatterns and Pitfalls by Mark Richards - https://oreil.ly/2J4r67x
  • 78. Bonus Microservice Anti-Pattern: Reach-In Reporting Solution • Async event publication • Encapsulation and independence of microservices is preserved • Performance is usually acceptable Source: Microservices AntiPatterns and Pitfalls by Mark Richards - https://oreil.ly/2J4r67x
  • 79. Key Takeaways • Cloud architecture abstracts away servers • Cache Aside pattern is great for performance improvements • Containers offer improved deployment and scaling options with less vendor lock-in • Microservices offer finer-grained control over app functionality • Federated Identity improves security and user experience • API Gateways help secure collections of services • Valet key provides cheaper, faster access to secure media • Consider Retry but you may need a Circuit-Breaker • Avoid the Reach In Reporting anti-pattern for your microservices @ardalis | Finding Patterns in the Clouds
  • 80. More Cloud Design Patterns https://bit.ly/1T8q2w8 @ardalis | Finding Patterns in the Clouds
  • 81. Thank You! • Contact me! twitter.com/ardalis [email protected] • Podcast WeeklyDevTips.com • Group Mentoring Program DevBetter.com • Free Microsoft eBooks ardalis.com/architecture-ebook ardalis.com/cloud-native-book