Introduction to Cloud Foundry
for Spring & Java Developers

Eric BOTTARD
Developer 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 clouds




Provide a choice of                         Bind a choice of
   development                                application
   frameworks                                  services


                      github.com/cloudfoundry

                             CONFIDENTIAL
CloudFoundry.COM – Multi-Tenant PaaS Operated by
VMware
                     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.13

VCAP_APP_PORT = 58121

VCAP_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
     instances

Google 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 edges

github.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 Practices
Eric BOTTARD
Developer Advocate
@ebottard / ebottard@vmware.com
Eric Bottard
  Developer Advocate • VMware


                t@ebottard
                Äericbottard
Agenda




10
         DOs &
         DON’Ts
          in the
         CLOUD
DISCLAIMER
CAPTAIN OBVIOUS! t-shirt available at threadless.com
Design by Nathan Stillie and Joshua Kemble
Http Traffic
        Latency Matters
Where’s the Data Center?
Where’s the Data Center?
LEARN
Lots of Literature
DIAGNOSE
Chrome Dev Tools
      YSlow
Google PageSpeed
FIX !
           Unique (e.g. hash) Paths
       Far Future Expires Header
                         Minification
                        CSS Sprites
                                CDN
Spring 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 THERE
But...
IT’S EPHEMERAL
(disappears on restarts)
IT’S NOT SHARED
           Either
Use Some Persistent


STORAGE
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
State
It’s Better Not To Have It
Try to be


STATELESS
Try to be


STATELESS
• Horizontal Scaling
Try to be


STATELESS
• Horizontal Scaling
• High Availability
Try to be


STATELESS
• Horizontal Scaling
• High Availability
• Zero Downtime Deploy
The Usual Suspects
The Usual Suspects

6’6”

6’0”

5’6”

5’0”

4’6”

4’0”
The Usual Suspects

6’6”

6’0”

5’6”

5’0”

4’6”

4’0”
The Usual Suspects

6’6”

6’0”

5’6”

5’0”

4’6”

4’0”
The Usual Suspects

6’6”

6’0”

5’6”

5’0”

4’6”

4’0”
The Usual Suspects
IF there is state




PUSH 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 tunnel

1: foobar-mq
2: foobar-pg
3: postgresql-handson-cf
Which service instance?> 3



1: none
2: psql
Which client would you like to start?> 2

Opening 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 ≠ Staging
Machines                   Identical
            ≠ Prod
             Manual,
Process                   Automated
           inconsistent

 People    Dev ≠ Ops       Devops
Traditional      Cloud
         Dev ≠ Staging
Machines                   Identical
            ≠ Prod
             Manual,
Process                   Automated
           inconsistent

 People    Dev ≠ Ops       Devops
Traditional      Cloud
         Dev ≠ Staging
Machines                   Identical
            ≠ Prod
             Manual,
Process                   Automated
           inconsistent

 People    Dev ≠ Ops       Devops
Traditional      Cloud
         Dev ≠ Staging
Machines                   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
SOA
This 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 it
cut -d" " -f1 < access.log | sort | uniq -c | sort -rn | less
Chances are they 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
Communication
SYNCH vs. ASYNCH
e.g. HTTP vs. AMQP
FORMAT
XML, JSON, PBuffers, Thrift
LOW TECH
Database + cron
When To Do It?
EARLY ON
YAGNI?
Slows Progress
NOW
Would be a Good Time
LATER ON
Now You Need It
Hard 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 INTEGRATION
Automatic builds, tests
CONTINUOUS DELIVERY
  CI + automatic deploy
IT’S OK
If 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 is


DIFFERENT
Every app is


DIFFERENT
• CPU
Every app is


DIFFERENT
• CPU
• RAM
Every app is


DIFFERENT
• CPU
• RAM
• DISK
Every app is


DIFFERENT
• CPU
• RAM
• DISK
• Bugs
Write your own logic




                       http://www.sxc.hu/photo/1128191
Write your own logic
Use   system-level metrics




                             http://www.sxc.hu/photo/1128191
Write your own logic
Use   system-level metrics
$vmc stats myapp
instance   #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 logic
Use   system-level metrics
$vmc stats myapp
instance   #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 logic
Use   Inter-process scaling
Write your own logic
Use   Inter-process scaling
$vmc scale myapp 
  --instances   3
  --memory      1G
Write your own logic
Use   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
Variations

1.Have some

 (privileged) population   Canary
 use N+1                   Release
Variations

1.Have some

 (privileged) population             Canary
 use N+1                             Release



                           2.then   roll out
Variations



               A|B
             Testing
Variations

1.Have some share of

 the population try      A|B
 a different version   Testing
Variations

1.Have some share of

 the population try      A|B
 a different version   Testing

2.then   decide
What about db
 changes?
BEFORE
Code @ Version N
Person
id
firstname
lastname
address
TRANSITION
Code @ Version N & N+1
Person        Address
id            id
firstname      person_id
lastname      street
address       zipcode
              city
              country
AFTER
     Code @ Version N+2
Person          Address
id              id
firstname        person_id
lastname        street
                zipcode
                city
                country
MIGRATIONS
Limit your Http      Traffic
     There is no File System

    Strive for Statelessness

Automate your DB Migrations

     Avoid Vendor Lock-in

     Treat all envs as Identical

It’s all about Loose Coupling

  Use Frequent Deployments

   Targeted and Custom Scaling

Upgrade with Zero Downtime
Thank You
  Eric Bottard
    Developer Advocate • VMware


                  t@ebottard
                  Äericbottard
          ebottard@vmware.com

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

  • 1.
    Introduction to CloudFoundry for Spring & Java Developers Eric BOTTARD Developer Advocate @ebottard / ebottard@vmware.com
  • 2.
    Eric Bottard Developer Advocate • VMware t@ebottard Äericbottard
  • 3.
    Cloud Stack -Classic Pyramid Software as a Service Platform as a Service Infrastructure as a Service
  • 4.
    Cloud Foundry –The Open Platform as a Service Target a choice of deployment clouds Provide a choice of Bind a choice of development application frameworks services github.com/cloudfoundry CONFIDENTIAL
  • 5.
    CloudFoundry.COM – Multi-TenantPaaS Operated by VMware CloudFoundry.COM (beta) Frameworks Services vCenter / vSphere Infrastructure
  • 6.
    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
  • 7.
    CloudFoundry.ORG – CommunityOpen 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
  • 8.
    CloudFoundry.ORG – CommunityOpen 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
  • 9.
    Main Risk: LockIn 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
  • 10.
    Cloud Foundry -Making Multi-Cloud a Reality Private Cloud Management and Public Cloud Distributions Deployment Operators .COM Bare metal CONFIDENTIAL
  • 11.
    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
  • 12.
  • 13.
    VCAP_* VCAP_APP_HOST = 192.168.1.13 VCAP_APP_PORT= 58121 VCAP_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
  • 14.
    Auto-reconfiguration § Works forSpring, 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
  • 15.
    Production Grade CloudFoundry 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 instances Google style problem è Google style solution CONFIDENTIAL
  • 16.
    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 edges github.com/cloudfoundry/bosh CONFIDENTIAL
  • 17.
    Key Takeaways § PaaSis 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
  • 18.
    Cloud Best Practices EricBOTTARD Developer Advocate @ebottard / ebottard@vmware.com
  • 19.
    Eric Bottard Developer Advocate • VMware t@ebottard Äericbottard
  • 20.
    Agenda 10 DOs & DON’Ts in the CLOUD
  • 21.
  • 22.
    CAPTAIN OBVIOUS! t-shirtavailable at threadless.com Design by Nathan Stillie and Joshua Kemble
  • 24.
    Http Traffic Latency Matters
  • 25.
  • 26.
  • 27.
  • 28.
    DIAGNOSE Chrome Dev Tools YSlow Google PageSpeed
  • 29.
    FIX ! Unique (e.g. hash) Paths Far Future Expires Header Minification CSS Sprites CDN Spring ResourceHandler Abstraction WRO4J / RoR Asset Pipeline
  • 30.
    FileSystem Just pretend it’s not there
  • 31.
    Is your Filethere? Is it Not?
  • 32.
    Is your Filethere? Is it Not?
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
    Use Some Persistent STORAGE • Mongo GridFS
  • 38.
    Use Some Persistent STORAGE • Mongo GridFS • Database Blob
  • 39.
    Use Some Persistent STORAGE • Mongo GridFS • Database Blob • External Blob Service
  • 40.
  • 41.
  • 42.
    Try to be STATELESS •Horizontal Scaling
  • 43.
    Try to be STATELESS •Horizontal Scaling • High Availability
  • 44.
    Try to be STATELESS •Horizontal Scaling • High Availability • Zero Downtime Deploy
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
    IF there isstate PUSH TO CLIENT (e.g. Cookie, HTML5 apps)
  • 52.
    IF there isstate USE CENTRAL SERVICE (e.g. Redis)
  • 53.
    IF there isstate MAKE IT PER USER + Sticky Sessions
  • 54.
    Databases They Have A Right To Evolve Too
  • 55.
    vmc tunnel (caldecott) $vmc tunnel 1: foobar-mq 2: foobar-pg 3: postgresql-handson-cf Which service instance?> 3 1: none 2: psql Which client would you like to start?> 2 Opening tunnel on port 10000...
  • 56.
  • 57.
    YOUR CODE ISVERSIONED* Why isn’t your DB? * It is, right?
  • 58.
    DON’T ROLL YOUROWN! (and beware of clusters)
  • 59.
    Don’t Roll yourOwn! MIGRATIONS
  • 60.
    Hotel California Better Stay Out of It
  • 61.
    Main Risk: LockIn 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
  • 62.
    Don’t Code to(any) Cloud!
  • 63.
    Don’t Code to(any) Cloud! § Auto-Reconfiguration
  • 64.
    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>
  • 65.
  • 66.
    Segregation All Environments Were Created Equal
  • 67.
    Dev vs. Testvs. Staging vs. Prod
  • 69.
    Traditional Cloud Dev ≠ Staging Machines Identical ≠ Prod Manual, Process Automated inconsistent People Dev ≠ Ops Devops
  • 70.
    Traditional Cloud Dev ≠ Staging Machines Identical ≠ Prod Manual, Process Automated inconsistent People Dev ≠ Ops Devops
  • 71.
    Traditional Cloud Dev ≠ Staging Machines Identical ≠ Prod Manual, Process Automated inconsistent People Dev ≠ Ops Devops
  • 72.
    Traditional Cloud Dev ≠ Staging Machines Identical ≠ Prod Manual, Process Automated inconsistent People Dev ≠ Ops Devops
  • 73.
    One app, Manydeploys Code Build Deployment Config
  • 74.
    One app, Manydeploys of ONE set les deliverab Code Build Deployment Config
  • 75.
    One app, Manydeploys of ONE set les deliverab Code Build Deployment Config ploys MANY de
  • 76.
    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
  • 77.
  • 78.
    Do your currentapps look like this? Tomcat .war Browser Apache MySQL
  • 80.
    SOA is like Adam Sandler’s career: Do one thing, and do it well. Rob Spectre, Developer Evangelism, Twilio
  • 81.
    Another way tolook at it cut -d" " -f1 < access.log | sort | uniq -c | sort -rn | less
  • 82.
    Chances are theywill 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
  • 83.
  • 84.
    SYNCH vs. ASYNCH e.g.HTTP vs. AMQP
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
    NOW Would be aGood Time
  • 90.
    LATER ON Now YouNeed It Hard To Refactor
  • 91.
    Spring Integration § Pipes& Filters Architecture § Promotes Loose Coupling • Handles the Plumbing for you § Declarative Model § Internal & External Messaging
  • 92.
    Deploy DoIt Early & Do It Often
  • 94.
  • 95.
    CONTINUOUS DELIVERY CI + automatic deploy
  • 96.
  • 97.
    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>
  • 98.
    Scale Yourown Way
  • 99.
  • 100.
  • 101.
  • 102.
    Every app is DIFFERENT •CPU • RAM • DISK
  • 103.
    Every app is DIFFERENT •CPU • RAM • DISK • Bugs
  • 104.
    Write your ownlogic http://www.sxc.hu/photo/1128191
  • 105.
    Write your ownlogic Use system-level metrics http://www.sxc.hu/photo/1128191
  • 106.
    Write your ownlogic Use system-level metrics $vmc stats myapp instance #0 cpu 0.0% of 2 cores memory 191.6M of 512M disk 15.0M of 2G http://www.sxc.hu/photo/1128191
  • 107.
    Write your ownlogic Use system-level metrics $vmc stats myapp instance #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
  • 108.
    Write your ownlogic Use Inter-process scaling
  • 109.
    Write your ownlogic Use Inter-process scaling $vmc scale myapp --instances 3 --memory 1G
  • 110.
    Write your ownlogic Use Inter-process scaling $vmc scale myapp --instances 3 --memory 1G as well as intra-process (thread pools)
  • 111.
    Upgrade With Zero Downtime
  • 112.
  • 113.
    Blue/Green Deployment $vmc appawesome awesome: running platform: spring on java usage: 512M × 1 instance urls: awesome.cloudfoundry.com services: postgresql-db
  • 114.
    Blue/Green Deployment $vmc appawesome awesome: running platform: spring on java usage: 512M × 1 instance urls: awesome.cloudfoundry.com services: postgresql-db Version N Version N Users LB / Proxy
  • 115.
    Blue/Green Deployment Version N Version N Users LB / Proxy
  • 116.
    Blue/Green Deployment $vmc push--name awesome_v2 --url awesome_secret.cloudfoundry.com Version N Version N Users LB / Proxy
  • 117.
    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
  • 118.
    Blue/Green Deployment Version N Version N Users LB / Proxy Version N+1 Version N+1
  • 119.
    Blue/Green Deployment $vmc unmpapawesome awesome.cloudfoundry.com $vmc map awesome_v2 awesome.cloudfoundry.com Version N Version N Users LB / Proxy Version N+1 Version N+1
  • 120.
    Blue/Green Deployment $vmc unmpapawesome awesome.cloudfoundry.com $vmc map awesome_v2 awesome.cloudfoundry.com Version N Version N Users LB / Proxy Version N+1 Version N+1
  • 121.
    Blue/Green Deployment $vmc unmpapawesome awesome.cloudfoundry.com $vmc map awesome_v2 awesome.cloudfoundry.com Version N Version N Users LB / Proxy Version N+1 Version N+1
  • 122.
    Variations Canary Release
  • 123.
    Variations 1.Have some (privileged)population Canary use N+1 Release
  • 124.
    Variations 1.Have some (privileged)population Canary use N+1 Release 2.then roll out
  • 125.
    Variations A|B Testing
  • 126.
    Variations 1.Have some shareof the population try A|B a different version Testing
  • 127.
    Variations 1.Have some shareof the population try A|B a different version Testing 2.then decide
  • 128.
  • 129.
    BEFORE Code @ VersionN Person id firstname lastname address
  • 130.
    TRANSITION Code @ VersionN & N+1 Person Address id id firstname person_id lastname street address zipcode city country
  • 131.
    AFTER Code @ Version N+2 Person Address id id firstname person_id lastname street zipcode city country
  • 132.
  • 133.
    Limit your Http Traffic There is no File System Strive for Statelessness Automate your DB Migrations Avoid Vendor Lock-in Treat all envs as Identical It’s all about Loose Coupling Use Frequent Deployments Targeted and Custom Scaling Upgrade with Zero Downtime
  • 134.
    Thank You Eric Bottard Developer Advocate • VMware t@ebottard Äericbottard ebottard@vmware.com