Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Devoxx France 2013 Cloud Best Practices

692 views

Published on

Published in: Technology
  • Is it true that openplatformasaservice.com invented open platform as a service and cloud foundry copied it?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Devoxx France 2013 Cloud Best Practices

  1. 1. Cloud Best Practices17h - 17h50 - Salle E. Fitzgerald & L. Amstrong 27 au 29 mars 2013
  2. 2. Cloud Best PracticesEric BOTTARDDeveloper Advocate@ebottard / ebottard@vmware.com
  3. 3. Eric Bottard Developer Advocate • VMware t@ebottard Äericbottard
  4. 4. 10 DOs & DON’Ts in the CLOUD
  5. 5. Cloud Stack - Classic Pyramid Software This Talk as a Service Platform as a Service Infrastructure as a Service
  6. 6. Cloud Foundry – The Open Platform as a Service Target a choice of deployment clouds Provide a choice of Bind a choice of applicationdevelopment frameworks services github.com/cloudfoundry CONFIDENTIAL
  7. 7. CloudFoundry.COM – Multi-Tenant PaaS Operated by VMware CloudFoundry.COM Frameworks Services VMware Infrastructure
  8. 8. CloudFoundry.ORG – Community Open Source Project CloudFoundry.ORG Community Frameworks Contributions Community Services Contributions Your Infrastructure Download Setup Environment Tool Chain & Deploy Behind Code Scripts Firewall Cloud Foundry BOSH Apache2 license CONFIDENTIAL
  9. 9. DISCLAIMER
  10. 10. CAPTAIN OBVIOUS! t-shirt available at threadless.comDesign by Nathan Stillie and Joshua Kemble
  11. 11. Http Traffic Latency Matters
  12. 12. Where’s the Data Center?
  13. 13. Where’s the Data Center?
  14. 14. LEARNLots of Literature
  15. 15. DIAGNOSEChrome Dev Tools YSlowGoogle PageSpeed
  16. 16. FIX ! Unique (e.g. hash) Paths Far Future Expires Header Minification CSS Sprites CDNSpring ResourceHandler Abstraction WRO4J / RoR Asset Pipeline
  17. 17. FileSystem Just pretend it’s not there
  18. 18. Is your File there? Is it Not?
  19. 19. Is your File there? Is it Not?
  20. 20. IT IS THEREBut...
  21. 21. IT’S EPHEMERAL(disappears on restarts)
  22. 22. IT’S NOT SHARED Either
  23. 23. Use Some PersistentSTORAGE
  24. 24. Use Some Persistent STORAGE• Mongo GridFS
  25. 25. Use Some Persistent STORAGE• Mongo GridFS• Database Blob
  26. 26. Use Some Persistent STORAGE• Mongo GridFS• Database Blob• External Blob Service
  27. 27. StateIt’s Better Not To Have It
  28. 28. Try to beSTATELESS
  29. 29. Try to be STATELESS• Horizontal Scaling
  30. 30. Try to be STATELESS• Horizontal Scaling• High Availability
  31. 31. Try to beSTATELESS• Horizontal Scaling• High Availability• Zero Downtime Deploy
  32. 32. The Usual Suspects
  33. 33. The Usual Suspects6’6”6’0”5’6”5’0”4’6”4’0”
  34. 34. The Usual Suspects6’6”6’0”5’6”5’0”4’6”4’0”
  35. 35. The Usual Suspects6’6”6’0”5’6”5’0”4’6”4’0”
  36. 36. The Usual Suspects6’6”6’0”5’6”5’0”4’6”4’0”
  37. 37. The Usual Suspects
  38. 38. IF there is statePUSH TO CLIENT(e.g. Cookie, HTML5 apps)
  39. 39. IF there is state USE CENTRAL SERVICE (e.g. Redis)
  40. 40. IF there is state MAKE IT PER USER + Sticky Sessions
  41. 41. Databases They Have A Right To Evolve Too
  42. 42. vmc tunnel (caldecott)$ vmc tunnel1: foobar-mq2: foobar-pg3: postgresql-handson-cfWhich service instance?> 31: none2: psqlWhich client would you like to start?> 2Opening tunnel on port 10000...
  43. 43. HUMAN.EQUALS(ERROR)(when they simply don’t forget)
  44. 44. YOUR CODE IS VERSIONED* Why isn’t your DB? * It is, right?
  45. 45. DON’T ROLL YOUR OWN! (and beware of clusters)
  46. 46. Don’t Roll your Own! MIGRATIONS
  47. 47. Hotel California Better Stay Out of It
  48. 48. Main Risk: Lock In Welcome to the hotel california Such a lovely place Such a lovely face Plenty of room at the hotel california Any time of year, you can find it here Last thing I remember, I was Running for the door I had to find the passage back To the place I was before ’relax,’ said the night man, We are programmed to receive. You can checkout any time you like, But you can never leave! -the Eagles
  49. 49. Don’t Code to (any) Cloud!
  50. 50. Don’t Code to (any) Cloud!§ Auto-Reconfiguration
  51. 51. Don’t Code to (any) Cloud! <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/§ Auto-Reconfiguration beans"...>§ For the Last 5% <bean id="mongoTemplate" class=" • Insulate your Code org.springframework.data.mongodb.core.MongoTemplate"> • Leverage Frameworks, e.g. Spring <constructor-arg ref="mongoDbFactory" /> Profiles </bean> <beans profile="default"> <mongo:db-factory id="mongoDbFactory" dbname="test" host="127.0.0.1" port="27017" username="foo" password="bar" /> </beans> <beans profile="cloud"> <cloud:mongo-db-factory id="mongoDbFactory" service-name="myBoundServiceName" /> </beans> </beans>
  52. 52. Beware of Data!
  53. 53. Segregation All Environments Were Created Equal
  54. 54. Dev vs. Test vs. Staging vs. Prod
  55. 55. Traditional CloudMachines Dev ≠ Staging ≠ Prod IdenticalProcess Manual, inconsistent Automated People Dev ≠ Ops Devops
  56. 56. Traditional CloudMachines Dev ≠ Staging ≠ Prod IdenticalProcess Manual, inconsistent Automated People Dev ≠ Ops Devops
  57. 57. Traditional CloudMachines Dev ≠ Staging ≠ Prod IdenticalProcess Manual, inconsistent Automated People Dev ≠ Ops Devops
  58. 58. Traditional CloudMachines Dev ≠ Staging ≠ Prod IdenticalProcess Manual, inconsistent Automated People Dev ≠ Ops Devops
  59. 59. One app, Many deploys Code Build Deployment Config
  60. 60. One app, Many deploys of ONE set les deliverab Code Build Deployment Config
  61. 61. One app, Many deploys of ONE set les deliverab Code Build Deployment Config loys M ANY dep
  62. 62. “ Environment Variables [...] unlike custom config files, or other config mechanisms such as Java System Properties, are a language- and OS-agnostic standard The Twelve Factor App, http://www.12factor.net
  63. 63. SOAThis time, it’s for real
  64. 64. Do your current apps look like this? Tomcat .war Browser Apache MySQL
  65. 65. “ SOA is like Adam Sandler’s career: Do one thing, and do it well. Rob Spectre, Developer Evangelism, Twilio
  66. 66. Another way to look at it cut -d" " -f1 < access.log | sort | uniq -c | sort -rn | less
  67. 67. Chances are your apps will soon look like this.. Tomcat search. war Desktop Browser Tomcat Native users. Node.js Message Bus war Mongo Mobile Front End e.g. RabbitMQ App HTML5 Mobile App Tomcat orders. war MySQL
  68. 68. Communication
  69. 69. SYNCH vs. ASYNCHe.g. HTTP vs. AMQP
  70. 70. FORMATXML, JSON, PBuffers, Thrift
  71. 71. LOW TECHDatabase + cron
  72. 72. When To Do It?
  73. 73. EARLY ONYAGNI?Slows Progress
  74. 74. NOWWould be a Good Time
  75. 75. LATER ONNow You Need ItHard To Refactor
  76. 76. Spring Integration§ Pipes & Filters Architecture§ Promotes Loose Coupling • Handles the Plumbing for you§ Declarative Model§ Internal & External Messaging
  77. 77. Deploy Do It Early & Do It Often
  78. 78. CONTINUOUS INTEGRATIONAutomatic builds, tests
  79. 79. CONTINUOUS DELIVERY CI + automatic deploy
  80. 80. IT’S OKIf it’s not PROD
  81. 81. Automate!<build> <plugins> <plugin> <groupId>org.cloudfoundry</groupId> <artifactId>maven-cf-plugin</artifactId> <version>1.0.0.M4-SNAPSHOT</version> <configuration> <server>mycloudfoundry-instance</server> <target>http://api.cloudfoundry.com</target> <appname>spring-integration-rocks</appname> <url>spring-int-rocks.cloudfoundry.com</url> <memory>1024</memory> ⊕ <services> <service> <name>mysql-test</name> <vendor>mysql</vendor> </service> <service> <name>mongodb-test</name> <vendor>mongodb</vendor> </service> </services> </configuration> </plugin> </plugins></build>
  82. 82. Scale Your own Way
  83. 83. Every app isDIFFERENT
  84. 84. Every app is DIFFERENT• CPU
  85. 85. Every app is DIFFERENT• CPU• RAM
  86. 86. Every app is DIFFERENT• CPU• RAM• DISK
  87. 87. Every app is DIFFERENT• CPU• RAM• DISK• Bugs
  88. 88. Write your own logic http://www.sxc.hu/photo/1128191
  89. 89. Write your own logicUse system-level metrics http://www.sxc.hu/photo/1128191
  90. 90. Write your own logicUse system-level metrics$vmc stats myappinstance #0 cpu 0.0% of 2 cores memory 191.6M of 512M disk 15.0M of 2G http://www.sxc.hu/photo/1128191
  91. 91. Write your own logicUse system-level metrics$vmc stats myappinstance #0 cpu 0.0% of 2 cores memory 191.6M of 512M disk 15.0M of 2G as well as business-related info http://www.sxc.hu/photo/1128191
  92. 92. Write your own logicUse Inter-process scaling
  93. 93. Write your own logicUse Inter-process scaling$vmc scale myapp --instances 3 --memory 1G
  94. 94. Write your own logicUse Inter-process scaling$vmc scale myapp --instances 3 --memory 1G as well as intra-process (thread pools)
  95. 95. Upgrade With Zero Downtime
  96. 96. Blue/Green Deployment
  97. 97. Blue/Green Deployment$vmc app awesome awesome: running platform: spring on java usage: 512M × 1 instance urls: awesome.cloudfoundry.com services: postgresql-db
  98. 98. Blue/Green Deployment$vmc app awesome awesome: running platform: spring on java usage: 512M × 1 instance urls: awesome.cloudfoundry.com services: postgresql-db Version N Version N Users LB / Proxy
  99. 99. Blue/Green Deployment Version N Version N Users LB / Proxy
  100. 100. Blue/Green Deployment$vmc push --name awesome_v2 --url awesome_secret.cloudfoundry.com Version N Version N Users LB / Proxy
  101. 101. Blue/Green Deployment$vmc push --name awesome_v2 --url awesome_secret.cloudfoundry.com Version N Version N Users LB / Proxy Version N+1 Version N+1
  102. 102. Blue/Green Deployment Version N Version N Users LB / Proxy Version N+1 Version N+1
  103. 103. Blue/Green Deployment$vmc unmpap awesome awesome.cloudfoundry.com$vmc map awesome_v2 awesome.cloudfoundry.com Version N Version N Users LB / Proxy Version N+1 Version N+1
  104. 104. Blue/Green Deployment$vmc unmpap awesome awesome.cloudfoundry.com$vmc map awesome_v2 awesome.cloudfoundry.com Version N Version N Users LB / Proxy Version N+1 Version N+1
  105. 105. Blue/Green Deployment$vmc unmpap awesome awesome.cloudfoundry.com$vmc map awesome_v2 awesome.cloudfoundry.com Version N Version N Users LB / Proxy Version N+1 Version N+1
  106. 106. Variations Canary Release
  107. 107. Variations1.Have some Canary (privileged) population Release use N+1
  108. 108. Variations1.Have some Canary (privileged) population Release use N+1 2.then roll out
  109. 109. Variations A|B Testing
  110. 110. Variations1.Have some share of the population try A|B a different version Testing
  111. 111. Variations1.Have some share of the population try A|B a different version Testing2.then decide
  112. 112. What about db changes?
  113. 113. BEFORECode @ Version NPersonidfirstnamelastnameaddress
  114. 114. TRANSITIONCode @ Version N & N+1Person Addressid idfirstname person_idlastname streetaddress zipcode city country
  115. 115. AFTER Code @ Version N+2Person Addressid idfirstname person_idlastname street zipcode city country
  116. 116. MIGRATIONS
  117. 117. Limit your Http Traffic There is no File System Strive for StatelessnessAutomate your DB Migrations Avoid Vendor Lock-in Treat all envs as IdenticalIt’s all about Loose Coupling Use Frequent Deployments Targeted and Custom ScalingUpgrade with Zero Downtime
  118. 118. ThankBottard You Eric Developer Advocate • VMware t@ebottard Äericbottard ebottard@vmware.com

×