LyonJUG - Combo - Quick Cloud Foundry Intro + Cloud Best Practices
Upcoming SlideShare
Loading in...5
×
 

LyonJUG - Combo - Quick Cloud Foundry Intro + Cloud Best Practices

on

  • 958 views

 

Statistics

Views

Total Views
958
Views on SlideShare
925
Embed Views
33

Actions

Likes
0
Downloads
5
Comments
0

3 Embeds 33

http://mj89sp3sau2k7lj1eg3k40hkeppguj6j-a-sites-opensocial.googleusercontent.com 18
https://twitter.com 14
https://si0.twimg.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

LyonJUG - Combo - Quick Cloud Foundry Intro + Cloud Best Practices LyonJUG - Combo - Quick Cloud Foundry Intro + Cloud Best Practices Presentation Transcript

  • Introduction to Cloud Foundryfor Spring & Java DevelopersEric BOTTARDDeveloper Advocate@ebottard / ebottard@vmware.com
  • Eric Bottard Developer Advocate • VMware t@ebottard Äericbottard
  • Cloud Stack - Classic Pyramid Software as a Service Platform as a Service Infrastructure as a Service
  • Cloud Foundry – The Open Platform as a Service Target a choice of deployment cloudsProvide a choice of Bind a choice of development application frameworks services github.com/cloudfoundry CONFIDENTIAL
  • CloudFoundry.COM – Multi-Tenant PaaS Operated byVMware CloudFoundry.COM (beta) Frameworks Services vCenter / vSphere Infrastructure
  • Micro Cloud FoundryTM – Cloud on a Stick Micro Cloud Foundry Frameworks Services Your Laptop/PC Single VM instance of Cloud Foundry that runs on a developer’s MAC or PC CONFIDENTIAL
  • CloudFoundry.ORG – Community Open Source Project CloudFoundry.ORG Community Frameworks Contributions Community Services Contributions Your Infrastructure Download Setup Tool Chain & Deploy Behind Code Environment Scripts Firewall Cloud Foundry BOSH Apache2 license CONFIDENTIAL
  • CloudFoundry.ORG – Community Open Source Project github.com/cloudfoundry§ .NET x 2 § Memcached§ PHP § SQL Server§ JRuby § Neo4j§ Python § CouchDB§ Rails 2.x § VirtualBox§ Clojure § Mono§ Erlang § Rack§ Haskell CONFIDENTIAL
  • 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 CONFIDENTIAL
  • Cloud Foundry - Making Multi-Cloud a Reality Private Cloud Management and Public Cloud Distributions Deployment Operators .COM Bare metal CONFIDENTIAL
  • Cloud Foundry: Clouds § AppFog.com • community lead for PHP • PaaS for PHP § Joyent • community lead for Node.js § ActiveState • community lead for Python, Perl • Providers of Stackato private PaaS CONFIDENTIAL
  • Demos
  • VCAP_*VCAP_APP_HOST = 192.168.1.13VCAP_APP_PORT = 58121VCAP_SERVICES ={ "redis-2.2": [ { "name": "my-redis-service", "label": "redis-2.2", "plan": "free", "tags": [ "key-value", "nosql", "redis-2.2", "redis" ], "credentials": { "hostname": "127.0.0.1", "host": "127.0.0.1", "port": 5000, "password": "ce7b483f-66d1-436d-8aa7-7c33a9ee31ac", "name": "e740add8-24ce-40f5-94ed-8a2623e0be57" } } ], "postgresql-9.0": [...]} 13
  • Auto-reconfiguration§ Works for Spring, Node, Ruby§ Spring: Uses a BeanFactoryPostProcessor under the hood • adds a jar to your app • modifies web.xml to load the BFPP • also adds correct jdbc driver jar§ Only works if no ambiguity (80% of apps) • One service of a kind CONFIDENTIAL
  • Production Grade Cloud Foundry Clusters§ 500 – 5,000 VMs cloudfoundry.com§ 40+ unique node types§ 75+ unique software packages§ 75+ unique environments§ 2x/week cf.com updates§ 24x7x365 non-stop operation§ No-downtime deployments§ Reliable, robust, repeatable deployments, updates, capacity adjustments§ Small teams manage many production, staging, stress, qa, dev instancesGoogle style problem è Google style solution CONFIDENTIAL
  • Cloud Foundry BOSH§ Cloud Foundry BOSH is an open source tool-chain for release engineering, deployment, and lifecycle management of large scale distributed services • Prescriptive way of creating releases and managing systems and services • It is not a collection of shell scripts, not a pile of Perl§ Built to deploy and manage production-class, large scale clusters • Production grade Cloud Foundry clusters: 500+ VMs, 40+ jobs, 75+ packages • Multi-node, multi-tier, complex clusters: e.g., our Gerrit/Jenkins Cluster§ Built for devops usage and scale by a crack team of veterans • A project, not a product: command line interface, YAML, etc. • Continuous improvement, iterative development, rough edgesgithub.com/cloudfoundry/bosh CONFIDENTIAL
  • Key Takeaways§ PaaS is the application platform for the Cloud era§ Cloud Foundry is the Industry’s Open PaaS • Developer agility • Portability without changes • Open system§ What’s next? • Free Signup: www.cloudfoundry.com (use “cloudtoday” as a promocode) • Get started: docs.cloudfoundry.com/getting-started.html • Learn more on the blog: blog.cloudfoundry.com • Download your Micro Cloud Foundry: my.cloudfoundry.com/micro • Get the source code: www.cloudfoundry.org • Follow us: @cloudfoundry • Watch us: www.youtube.com/cloudfoundry CONFIDENTIAL
  • Cloud Best PracticesEric BOTTARDDeveloper Advocate@ebottard / ebottard@vmware.com
  • Eric Bottard Developer Advocate • VMware t@ebottard Äericbottard
  • Agenda10 DOs & DON’Ts in the CLOUD
  • DISCLAIMER
  • CAPTAIN OBVIOUS! t-shirt available at threadless.comDesign by Nathan Stillie and Joshua Kemble
  • Http Traffic Latency Matters
  • Where’s the Data Center?
  • Where’s the Data Center?
  • LEARNLots of Literature
  • DIAGNOSEChrome Dev Tools YSlowGoogle PageSpeed
  • FIX ! Unique (e.g. hash) Paths Far Future Expires Header Minification CSS Sprites CDNSpring ResourceHandler Abstraction WRO4J / RoR Asset Pipeline
  • FileSystem Just pretend it’s not there
  • Is your File there? Is it Not?
  • Is your File there? Is it Not?
  • IT IS THEREBut...
  • IT’S EPHEMERAL(disappears on restarts)
  • IT’S NOT SHARED Either
  • Use Some PersistentSTORAGE
  • Use Some Persistent STORAGE• Mongo GridFS
  • Use Some Persistent STORAGE• Mongo GridFS• Database Blob
  • Use Some Persistent STORAGE• Mongo GridFS• Database Blob• External Blob Service
  • StateIt’s Better Not To Have It
  • Try to beSTATELESS
  • Try to beSTATELESS• Horizontal Scaling
  • Try to beSTATELESS• Horizontal Scaling• High Availability
  • Try to beSTATELESS• Horizontal Scaling• High Availability• Zero Downtime Deploy
  • The Usual Suspects
  • The Usual Suspects6’6”6’0”5’6”5’0”4’6”4’0”
  • The Usual Suspects6’6”6’0”5’6”5’0”4’6”4’0”
  • The Usual Suspects6’6”6’0”5’6”5’0”4’6”4’0”
  • The Usual Suspects6’6”6’0”5’6”5’0”4’6”4’0”
  • The Usual Suspects
  • IF there is statePUSH TO CLIENT(e.g. Cookie, HTML5 apps)
  • IF there is state USE CENTRAL SERVICE (e.g. Redis)
  • IF there is state MAKE IT PER USER + Sticky Sessions
  • Databases They Have A Right To Evolve Too
  • 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...
  • HUMAN.EQUALS(ERROR)(when they simply don’t forget)
  • YOUR CODE IS VERSIONED* Why isn’t your DB? * It is, right?
  • DON’T ROLL YOUR OWN! (and beware of clusters)
  • Don’t Roll your Own! MIGRATIONS
  • Hotel California Better Stay Out of It
  • 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
  • Don’t Code to (any) Cloud!
  • Don’t Code to (any) Cloud!§ Auto-Reconfiguration
  • Don’t Code to (any) Cloud!§ Auto-Reconfiguration§ For the Last 5% • Insulate your Code • Leverage Frameworks, e.g. Spring Profiles <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"...> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg ref="mongoDbFactory" /> </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>
  • Beware of Data!
  • Segregation All Environments Were Created Equal
  • Dev vs. Test vs. Staging vs. Prod
  • Traditional Cloud Dev ≠ StagingMachines Identical ≠ Prod Manual,Process Automated inconsistent People Dev ≠ Ops Devops
  • Traditional Cloud Dev ≠ StagingMachines Identical ≠ Prod Manual,Process Automated inconsistent People Dev ≠ Ops Devops
  • Traditional Cloud Dev ≠ StagingMachines Identical ≠ Prod Manual,Process Automated inconsistent People Dev ≠ Ops Devops
  • Traditional Cloud Dev ≠ StagingMachines Identical ≠ Prod Manual,Process Automated inconsistent People Dev ≠ Ops Devops
  • One app, Many deploys Code Build Deployment Config
  • One app, Many deploys of ONE set les deliverab Code Build Deployment Config
  • One app, Many deploys of ONE set les deliverab Code Build Deployment Config ploys MANY de
  • “ 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
  • SOAThis time, it’s for real
  • Do your current apps look like this? Tomcat .war Browser Apache MySQL
  • “ SOA is like Adam Sandler’s career: Do one thing, and do it well. Rob Spectre, Developer Evangelism, Twilio
  • Another way to look at itcut -d" " -f1 < access.log | sort | uniq -c | sort -rn | less
  • Chances are they will soon look like this.. Tomcat search. warDesktopBrowser TomcatNative users. Node.js Message Bus war MongoMobile Front End e.g. RabbitMQ AppHTML5Mobile App Tomcat orders. war MySQL
  • Communication
  • SYNCH vs. ASYNCHe.g. HTTP vs. AMQP
  • FORMATXML, JSON, PBuffers, Thrift
  • LOW TECHDatabase + cron
  • When To Do It?
  • EARLY ONYAGNI?Slows Progress
  • NOWWould be a Good Time
  • LATER ONNow You Need ItHard To Refactor
  • Spring Integration§ Pipes & Filters Architecture§ Promotes Loose Coupling • Handles the Plumbing for you§ Declarative Model§ Internal & External Messaging
  • Deploy Do It Early & Do It Often
  • CONTINUOUS INTEGRATIONAutomatic builds, tests
  • CONTINUOUS DELIVERY CI + automatic deploy
  • IT’S OKIf it’s not PROD
  • 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>
  • Scale Your own Way
  • Every app isDIFFERENT
  • Every app isDIFFERENT• CPU
  • Every app isDIFFERENT• CPU• RAM
  • Every app isDIFFERENT• CPU• RAM• DISK
  • Every app isDIFFERENT• CPU• RAM• DISK• Bugs
  • Write your own logic http://www.sxc.hu/photo/1128191
  • Write your own logicUse system-level metrics http://www.sxc.hu/photo/1128191
  • 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
  • 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
  • Write your own logicUse Inter-process scaling
  • Write your own logicUse Inter-process scaling$vmc scale myapp --instances 3 --memory 1G
  • Write your own logicUse Inter-process scaling$vmc scale myapp --instances 3 --memory 1G as well as intra-process (thread pools)
  • Upgrade With Zero Downtime
  • Blue/Green Deployment
  • Blue/Green Deployment$vmc app awesome awesome: running platform: spring on java usage: 512M × 1 instance urls: awesome.cloudfoundry.com services: postgresql-db
  • 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
  • Blue/Green Deployment Version N Version N Users LB / Proxy
  • Blue/Green Deployment$vmc push --name awesome_v2 --url awesome_secret.cloudfoundry.com Version N Version N Users LB / Proxy
  • 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
  • Blue/Green Deployment Version N Version N Users LB / Proxy Version N+1 Version N+1
  • 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
  • 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
  • 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
  • Variations Canary Release
  • Variations1.Have some (privileged) population Canary use N+1 Release
  • Variations1.Have some (privileged) population Canary use N+1 Release 2.then roll out
  • Variations A|B Testing
  • Variations1.Have some share of the population try A|B a different version Testing
  • Variations1.Have some share of the population try A|B a different version Testing2.then decide
  • What about db changes?
  • BEFORECode @ Version NPersonidfirstnamelastnameaddress
  • TRANSITIONCode @ Version N & N+1Person Addressid idfirstname person_idlastname streetaddress zipcode city country
  • AFTER Code @ Version N+2Person Addressid idfirstname person_idlastname street zipcode city country
  • MIGRATIONS
  • 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
  • Thank You Eric Bottard Developer Advocate • VMware t@ebottard Äericbottard ebottard@vmware.com