8 Cloud Design Patterns you
ought to know
Taswar Bhatti
System/Solutions Architect at Gemalto (Canada)
Microsoft MVP
Ponder
• For every 25 percent increase in problem complexity, there is a 100
percent increase in solution complexity.
• There is seldom one best design solution to a software problem.
• If cars were like software, they would crash twice a day for no reason,
and when you called for service, they’d tell you to reinstall the engine.
Who am I
• Taswar Bhatti – Microsoft MVP since 2014
• Global Solutions Architect/System Architect at Gemalto
• In Software Industry since 2000
• I know Kung Fu (Languages)
What I am not
Agenda
• What are Patterns?
• The External Configuration Pattern
• The Cache Aside Pattern
• The Federated Identity Pattern
• The Valet Key Pattern
• The Gatekeeper Pattern
• The Circuit Breaker Pattern
• The Retry Pattern
• The Strangler Pattern
• Demo
• Questions
Bad Design
Bad Design
Bad Design
Bad Design
Bad Design
Feature doesn’t make sense????
Anger
Bad day at work
Happy family
Next day at work
Ship it
Customer Feature didn’t make sense
Bad Design?
Itunes when I use it
What are Patterns?
• General reusable solution to a recurring problem
• A template on how to solve a problem
• Best practices
• Patterns allow developers communicate with each other in well
known and understand names for software interactions.
External Configuration Pattern
External Configuration Pattern
• Helps move configuration information out of the application
deployment
• This pattern can provide for easier management and control of
configuration data
• For sharing configuration data across applications and other
application instances
Typical Application
Storing Configuration in file
Multiple application
Problems
• Configuration becomes part of deployment
• Multiple applications share the same configuration
• Hard to have access control over the configuration
External Configuration Pattern
When to use the pattern
• When you have shared configuration, multiple application
• You want to manage configuration centrally by DevOps
• Provide audit for each configuration
When not to use
• When you only have a single application there is no need to use this
pattern it will make things more complex
Cloud Solution Offerings
• Azure Key Vault
• Vault by Hashicorp
• AWS KMS
• Keywhiz
Demo KeyVault
Cache Aside Pattern
Cache Aside Pattern
• Load data on demand into a cache from datastore
• Helps improve performance
• Helps in maintain consistency between data held in the cache and
data in the underlying data store.
Typical Application
Cache Aside Pattern
When to use the pattern
• Resource demand is unpredictable.
• This pattern enables applications to load data on demand
• It makes no assumptions about which data an application will require
in advance
When not to use
• Don’t use it for data that changes very often
Things to consider
• Sometimes data can be changed from outside process
• Have an expiry for the data in cache
• When update of data, invalidate the cache before updating the data
in database
• Pre populate the data if possible
Cloud Offerings
• Redis (Azure and AWS)
• Memcache
• Hazelcast
• Elastic Cache (AWS)
Federated Identity Pattern
Federated Identity Pattern
• Delegate authentication to an external identity provider.
• Simplify development, minimize the requirement for user
administration
• Improve the user experience of the application
• Centralized providing MFA for user authentication
Typical Application
Problem
Problem
• Complex development and maintenance (Duplicated code)
• MFA is not an easy thing
• User administration is a pain with access control
• Hard to keep system secure
• No single sign on (SSO) everyone needs to login again to different
systems
Federated Identity Pattern
When to use
• When you have multiple applications and want to provide SSO for
applications
• Federated identity with multiple partners
• Federated identity in SAAS application
When not to use it
• You already have a single application and have custom code that
allows you to login
Things to consider
• The identity Server needs to be highly available
• Single point of failure, must have HA
• RBAC, identity server usually does not have authorization information
• Claims and scope within the security auth token
Cloud Offerings
• Azure AD
• Gemalto STA and SAS
• Amazon IAM
• GCP Cloud IAM
Valet Key Pattern
Valet Key Pattern
• Use a token that provides clients with restricted direct access to a
specific resource
• Provide offload data transfer from the application
• Minimize cost and maximize scalability and performance
Typical Application
Client App Storage
Problem
Client App Storage
Client
Client Client
Client
Valet Key Pattern
Client App
Generate Token
Limited Time
And Scope
Storage
When to use it
• The application has limited resources
• To minimize operational cost
• Many interaction with external resources (upload, download)
• When the data is stored in a remote data store or a different
datacenter
When not to use it
• When you need to transform the data before upload or download
Cloud Offerings
• Azure Blob Storage
• Amazon S3
• GCP Cloud Storage
Gatekeeper Pattern
Gatekeeper Pattern
• Using a dedicated host instance that acts as a broker between clients
and services
• Protect applications and services
• Validates and sanitizes requests, and passes requests and data
between them
• Provide an additional layer of security, and limit the attack surface of
the system
Typical Application
Problem
Gatekeeper Pattern
When to use it
• Sensitive information (Health care, Authentication)
• Distributed System where perform request validation separately
When not to use
• Performance vs security
Things to consider
• WAF should not hold any keys or sensitive information
• Use a secure communication channel
• Auto scale
• Endpoint IP address (when scaling application does the WAF know
the new applications)
Circuit Breaker Pattern
Circuit Breaker Pattern
• To handle faults that might take a variable amount of time to recover
• When connecting to a remote service or resource
Typical Application
Problem
Client
Circuit
Breaker
Api
Closed State
Timeout
Closed State
Open State
Half Open State
After X Retry
Closed State
Circuit Breaker
When to use it
• To prevent an application from trying to invoke a remote service or
access a shared resource if this operation is highly likely to fail
• Better user experience
When not to use
• Handling access to local private resources in an application, such as
in-memory data structure
• Creates an overhead
• Not a substitute for handling exceptions in the business logic of your
applications
Libraries
• Polly (http://www.thepollyproject.org/)
• Netflix (Hystrix) https://github.com/Netflix/Hystrix/wiki
Retry pattern
Retry Pattern
• Enable an application to handle transient failures
• When the applications tries to connect to a service or network
resource
• By transparently retrying a failed operation
Typical Application
Network Failure
Retry Pattern
• Retry after 2, 5 or 10 seconds
When to use it
• Use retry for only transient failure that is more than likely to resolve
themselves quickly
• Match the retry policies with the application
• Otherwise use the circuit break pattern
When not to use it
• Don’t cause a chain reaction to all components
• For internal exceptions caused by business logic
• Log all retry attempts to the service
Libraries
• Roll your own code
• Polly (http://www.thepollyproject.org/)
• Netflix (Hystrix) https://github.com/Netflix/Hystrix/wiki
Demo Retry
Strangler Pattern
Strangler Pattern
• Incrementally migrate a legacy system
• Gradually replacing specific pieces of functionality with new
applications and services
• Features from the legacy system are replaced by new system features
eventually
• Strangling the old system and allowing you to decommission it
Monolith Application
Strangler Pattern
When to use
• Gradually migrating a back-end application to a new architecture
When not to use
• When requests to the back-end system cannot be intercepted
• For smaller systems where the complexity of wholesale replacement
is low
Considerations
• Handle services and data stores that are potentially used by both new
and legacy systems.
• Make sure both can access these resources side-by-side
• When migration is complete, the strangler façade will either go away
or evolve into an adaptor for legacy clients
• Make sure the façade doesn't become a single point of failure or a
performance bottleneck.
Questions?
Taswar Bhatti
System Solutions Architect (Gemalto)
Microsoft MVP
http://taswar.zeytinsoft.com
@taswarbhatti
Credits
• For the background
• www.Vecteezy.com

8 cloud design patterns you ought to know - Update Conference 2018

  • 1.
    8 Cloud DesignPatterns you ought to know Taswar Bhatti System/Solutions Architect at Gemalto (Canada) Microsoft MVP
  • 2.
    Ponder • For every25 percent increase in problem complexity, there is a 100 percent increase in solution complexity. • There is seldom one best design solution to a software problem. • If cars were like software, they would crash twice a day for no reason, and when you called for service, they’d tell you to reinstall the engine.
  • 3.
    Who am I •Taswar Bhatti – Microsoft MVP since 2014 • Global Solutions Architect/System Architect at Gemalto • In Software Industry since 2000 • I know Kung Fu (Languages)
  • 4.
  • 6.
    Agenda • What arePatterns? • The External Configuration Pattern • The Cache Aside Pattern • The Federated Identity Pattern • The Valet Key Pattern • The Gatekeeper Pattern • The Circuit Breaker Pattern • The Retry Pattern • The Strangler Pattern • Demo • Questions
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 22.
    What are Patterns? •General reusable solution to a recurring problem • A template on how to solve a problem • Best practices • Patterns allow developers communicate with each other in well known and understand names for software interactions.
  • 23.
  • 24.
    External Configuration Pattern •Helps move configuration information out of the application deployment • This pattern can provide for easier management and control of configuration data • For sharing configuration data across applications and other application instances
  • 25.
  • 26.
  • 27.
  • 28.
    Problems • Configuration becomespart of deployment • Multiple applications share the same configuration • Hard to have access control over the configuration
  • 29.
  • 30.
    When to usethe pattern • When you have shared configuration, multiple application • You want to manage configuration centrally by DevOps • Provide audit for each configuration
  • 31.
    When not touse • When you only have a single application there is no need to use this pattern it will make things more complex
  • 32.
    Cloud Solution Offerings •Azure Key Vault • Vault by Hashicorp • AWS KMS • Keywhiz
  • 33.
  • 34.
  • 35.
    Cache Aside Pattern •Load data on demand into a cache from datastore • Helps improve performance • Helps in maintain consistency between data held in the cache and data in the underlying data store.
  • 36.
  • 37.
  • 38.
    When to usethe pattern • Resource demand is unpredictable. • This pattern enables applications to load data on demand • It makes no assumptions about which data an application will require in advance
  • 39.
    When not touse • Don’t use it for data that changes very often
  • 40.
    Things to consider •Sometimes data can be changed from outside process • Have an expiry for the data in cache • When update of data, invalidate the cache before updating the data in database • Pre populate the data if possible
  • 41.
    Cloud Offerings • Redis(Azure and AWS) • Memcache • Hazelcast • Elastic Cache (AWS)
  • 42.
  • 43.
    Federated Identity Pattern •Delegate authentication to an external identity provider. • Simplify development, minimize the requirement for user administration • Improve the user experience of the application • Centralized providing MFA for user authentication
  • 44.
  • 45.
  • 46.
    Problem • Complex developmentand maintenance (Duplicated code) • MFA is not an easy thing • User administration is a pain with access control • Hard to keep system secure • No single sign on (SSO) everyone needs to login again to different systems
  • 47.
  • 48.
    When to use •When you have multiple applications and want to provide SSO for applications • Federated identity with multiple partners • Federated identity in SAAS application
  • 49.
    When not touse it • You already have a single application and have custom code that allows you to login
  • 50.
    Things to consider •The identity Server needs to be highly available • Single point of failure, must have HA • RBAC, identity server usually does not have authorization information • Claims and scope within the security auth token
  • 51.
    Cloud Offerings • AzureAD • Gemalto STA and SAS • Amazon IAM • GCP Cloud IAM
  • 52.
  • 53.
    Valet Key Pattern •Use a token that provides clients with restricted direct access to a specific resource • Provide offload data transfer from the application • Minimize cost and maximize scalability and performance
  • 54.
  • 55.
  • 56.
    Valet Key Pattern ClientApp Generate Token Limited Time And Scope Storage
  • 57.
    When to useit • The application has limited resources • To minimize operational cost • Many interaction with external resources (upload, download) • When the data is stored in a remote data store or a different datacenter
  • 58.
    When not touse it • When you need to transform the data before upload or download
  • 59.
    Cloud Offerings • AzureBlob Storage • Amazon S3 • GCP Cloud Storage
  • 60.
  • 61.
    Gatekeeper Pattern • Usinga dedicated host instance that acts as a broker between clients and services • Protect applications and services • Validates and sanitizes requests, and passes requests and data between them • Provide an additional layer of security, and limit the attack surface of the system
  • 62.
  • 63.
  • 64.
  • 65.
    When to useit • Sensitive information (Health care, Authentication) • Distributed System where perform request validation separately
  • 66.
    When not touse • Performance vs security
  • 67.
    Things to consider •WAF should not hold any keys or sensitive information • Use a secure communication channel • Auto scale • Endpoint IP address (when scaling application does the WAF know the new applications)
  • 68.
  • 69.
    Circuit Breaker Pattern •To handle faults that might take a variable amount of time to recover • When connecting to a remote service or resource
  • 70.
  • 71.
  • 72.
    Client Circuit Breaker Api Closed State Timeout Closed State OpenState Half Open State After X Retry Closed State
  • 73.
  • 74.
    When to useit • To prevent an application from trying to invoke a remote service or access a shared resource if this operation is highly likely to fail • Better user experience
  • 75.
    When not touse • Handling access to local private resources in an application, such as in-memory data structure • Creates an overhead • Not a substitute for handling exceptions in the business logic of your applications
  • 76.
    Libraries • Polly (http://www.thepollyproject.org/) •Netflix (Hystrix) https://github.com/Netflix/Hystrix/wiki
  • 77.
  • 78.
    Retry Pattern • Enablean application to handle transient failures • When the applications tries to connect to a service or network resource • By transparently retrying a failed operation
  • 79.
  • 80.
    Retry Pattern • Retryafter 2, 5 or 10 seconds
  • 81.
    When to useit • Use retry for only transient failure that is more than likely to resolve themselves quickly • Match the retry policies with the application • Otherwise use the circuit break pattern
  • 82.
    When not touse it • Don’t cause a chain reaction to all components • For internal exceptions caused by business logic • Log all retry attempts to the service
  • 83.
    Libraries • Roll yourown code • Polly (http://www.thepollyproject.org/) • Netflix (Hystrix) https://github.com/Netflix/Hystrix/wiki
  • 84.
  • 85.
  • 86.
    Strangler Pattern • Incrementallymigrate a legacy system • Gradually replacing specific pieces of functionality with new applications and services • Features from the legacy system are replaced by new system features eventually • Strangling the old system and allowing you to decommission it
  • 87.
  • 88.
  • 89.
    When to use •Gradually migrating a back-end application to a new architecture
  • 90.
    When not touse • When requests to the back-end system cannot be intercepted • For smaller systems where the complexity of wholesale replacement is low
  • 91.
    Considerations • Handle servicesand data stores that are potentially used by both new and legacy systems. • Make sure both can access these resources side-by-side • When migration is complete, the strangler façade will either go away or evolve into an adaptor for legacy clients • Make sure the façade doesn't become a single point of failure or a performance bottleneck.
  • 92.
    Questions? Taswar Bhatti System SolutionsArchitect (Gemalto) Microsoft MVP http://taswar.zeytinsoft.com @taswarbhatti
  • 93.
    Credits • For thebackground • www.Vecteezy.com

Editor's Notes

  • #3 For every 25 percent increase in problem complexity, there is a 100 percent increase in solution complexity. There is seldom one best design solution to a software problem. If cars were like software, they would crash twice a day for no reason, and when you called for service, they’d tell you to reinstall the engine.