Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Design Patterns for The Cloud (010dev Rotterdam)

Design Patterns for The Cloud (010dev Rotterdam)

Even Platform as a Service promise to host your application without a change, things are not so simple and you can't send your old EJB 1.0 application to the Cloud without some refactoring. During this session, I'll explain some architecture patterns to apply to your new developments so that your transition to the cloud is as smooth as possible.

Cyrille Le Clerc

June 27, 2013
Tweet

More Decks by Cyrille Le Clerc

Other Decks in Technology

Transcript

  1. ©2013 CloudBees, Inc. All Rights Reserved Design Patterns for the

    Cloud Rethinking application design for the Cloud Cyrille Le Clerc 010DEV.nl Monday, June 24, 13
  2. ©2013 CloudBees, Inc. All Rights Reserved Speaker 2 Cyrille Le

    Clerc @cyrilleleclerc Open Source CTO DevOps, Infra as Code Solution Architect Cloud Monday, June 24, 13
  3. ©2013 CloudBees, Inc. All Rights Reserved This talk is 3

    Greatly inspired by Nicolas de Loof’s presentation Thanks Nicolas! Monday, June 24, 13
  4. ©2013 CloudBees, Inc. All Rights Reserved IaaS, PaaS & SaaS

    4 Infrastructure as a Service Platform as a Service Software as a Service Linux + storage + network App runtime + middleware Managed “Traditional” admin Business App Managed Monday, June 24, 13
  5. ©2013 CloudBees, Inc. All Rights Reserved Cloud 㲗 On Premises

    6 Cloud On Premises Easy Maybe difficult for legacy apps Monday, June 24, 13
  6. ©2013 CloudBees, Inc. All Rights Reserved Cloud 㲗 On Premises

    6 Cloud On Premises Easy Maybe difficult for legacy apps refactor Monday, June 24, 13
  7. ©2013 CloudBees, Inc. All Rights Reserved Green Field Applications 7

    • Can select modern solutions Most (not all) frameworks are well designed for Cloud • Started on cloud, discover and adapt to constraints Monday, June 24, 13
  8. ©2013 CloudBees, Inc. All Rights Reserved “Legacy” Applications 8 •

    Not so modern solutions old frameworks and patterns may not fit with cloud constraints • Started on premises, single server hit cloud constraints Monday, June 24, 13
  9. ©2013 CloudBees, Inc. All Rights Reserved Scale Up 10 M1

    Small M1 Large M3 2 XLarge •Still possible, but up to a limit •Not optimal Monday, June 24, 13
  10. ©2013 CloudBees, Inc. All Rights Reserved Scale Up 10 M1

    Small M1 Large M3 2 XLarge •Still possible, but up to a limit •Not optimal Low utilization! Monday, June 24, 13
  11. ©2013 CloudBees, Inc. All Rights Reserved Scale Up 10 M1

    Small M1 Large M3 2 XLarge •Still possible, but up to a limit •Not optimal Then ??? Low utilization! Monday, June 24, 13
  12. ©2013 CloudBees, Inc. All Rights Reserved M1 Extra Large •

    64 bits • 15 Gb memory • 4 Vcore, 2 cpu unit (~2.5Gh) • 1.6 Tb HD • aka « your desktop » 11 Monday, June 24, 13
  13. ©2013 CloudBees, Inc. All Rights Reserved Scale out 12 Design

    for clustering Scale as you need Pay as you use Monday, June 24, 13
  14. ©2013 CloudBees, Inc. All Rights Reserved Multi tenancy - PaaS

    backstage 13 • Multi tenancy at the app level, not at the OS level • Slice big servers into slices tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x tomcat app-x Monday, June 24, 13
  15. ©2013 CloudBees, Inc. All Rights Reserved Multi Tenancy • OS

    level (hypervisor): IaaS • OS virtualization (cgroups, LXC): PaaS • Middleware ? Java 9 to be multi-tenant ? • Application: SaaS 14 Monday, June 24, 13
  16. ©2013 CloudBees, Inc. All Rights Reserved An Ideal Stateless RestFul

    World 16 Linear horizontal scaling But … • Application / User « conversation » has a state • Stateless apps often store state in a database! Monday, June 24, 13
  17. ©2013 CloudBees, Inc. All Rights Reserved State Are you really

    stateless ? Beware of your framework! 17 Grails Spring Security Security Plugins Http Session Monday, June 24, 13
  18. ©2013 CloudBees, Inc. All Rights Reserved Really stateless ? •

    Client side state with browser cookies →higher network traffic, security • Use http session (servlet frameworks) →memcache session replication →sticky session • Use a central service (DB) → SPoF, DB scalability 18 Monday, June 24, 13
  19. ©2013 CloudBees, Inc. All Rights Reserved Cloud uses Schrödinger FS

    20 Looks like it’s alive, but it’s not anymore Monday, June 24, 13
  20. ©2013 CloudBees, Inc. All Rights Reserved IaaS / PaaS ==

    Pool of Servers 21 Your host at his time Your host after a redeployment Monday, June 24, 13
  21. ©2013 CloudBees, Inc. All Rights Reserved Don’t trust the local

    FS 22 • File System is ephemeral and NOT distributed ... at least on Amazon • Use a storage engine à la Amazon S3 ... and see the local FS as a cache Monday, June 24, 13
  22. ©2013 CloudBees, Inc. All Rights Reserved Singletons aren’t 24 •

    Most app servers are NOT clusterized with reliable singletons • Use Cron as a Service like iron.io ... or trust Quartz with a JDBC store Cloud Service Architecture Monday, June 24, 13
  23. ©2013 CloudBees, Inc. All Rights Reserved Latency Matters 26 tomcat

    app-x 120ms • Inter Continental is common • EU to us-east-1 latency: 120ms Monday, June 24, 13
  24. ©2013 CloudBees, Inc. All Rights Reserved Measure • Chrome Dev

    Tools • Google Pagespeed • YSlow 27 Monday, June 24, 13
  25. ©2013 CloudBees, Inc. All Rights Reserved Improve • HTTP Headers:

    Expires & Cache Control • Use CDNs (Content Delivery Network) 28 Monday, June 24, 13
  26. ©2013 CloudBees, Inc. All Rights Reserved *aaS Ecosystem 30 •

    *aaS is about service, not software • Integrate services, don’t try to setup your own infrastructure • Amazon AWS, the place to be for *aaS Monday, June 24, 13
  27. ©2013 CloudBees, Inc. All Rights Reserved Private Cloud ? Non

    sense ? 32 • Size matters! • Ecosystem matters! • You already delegate hosting! • Security: humans vs. firewalls • Cloud is secure Monday, June 24, 13
  28. ©2013 CloudBees, Inc. All Rights Reserved It may Will fail!

    34 http://status.cloudbees.com http://status.aws.amazon.com/ Monday, June 24, 13
  29. ©2013 CloudBees, Inc. All Rights Reserved Design for Failure 35

    • Don’t fail if a resource is KO • Be asynchronous and fault tolerant • Use messaging • NoSQL is your friend SNS SQS Monday, June 24, 13
  30. ©2013 CloudBees, Inc. All Rights Reserved •Git push •Build •Test

    •Ready for production •Production •Git push •Build •Test •Deploy •Production Continuous Delivery 37 •Git push •Build •Test Integration Deployment Delivery Monday, June 24, 13
  31. ©2013 CloudBees, Inc. All Rights Reserved Blue Green Deployment 38

    • Martin Fowler: http://martinfowler.com/ bliki/BlueGreenDeployment.html • Zero Downtime • Cloud Elasticity → 2x number of servers during deployment • NoSQL is your friend Monday, June 24, 13
  32. ©2013 CloudBees, Inc. All Rights Reserved Feature Toggle Pattern •

    Continuous merging in the “trunk” • Deploy not yet ready code • Enable / disable features with a switch, no redeployment, often no restart 39 JMX persistent transient AntiFraudServiceV1Impl AntiFraudServiceV2Impl AntiFraudService DispatchingImpl AntiFraudService <<Interface>> Monday, June 24, 13
  33. ©2013 CloudBees, Inc. All Rights Reserved A/B Testing • Test

    different UI / Features • Measure the impacy 40 Monday, June 24, 13
  34. ©2013 CloudBees, Inc. All Rights Reserved Canary Testing • Test

    new versions on a limited panel of users 41 Monday, June 24, 13