SlideShare uma empresa Scribd logo
1 de 66
Baixar para ler offline
Thinking Outside the Container:
                         Deploying Standalone Apps to Cloud Foundry
                                                                                    Jennifer Hickey




             © 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.

Saturday, October 20, 2012
About Jennifer
        • Engineer @ Cloud Foundry
        • Focused on framework support
        • Long time SpringSource-er
        • Contributed to many Spring and SpringSource projects
        • Passionate about increasing developer productivity in the
          cloud.
          Contact Info
            Twitter: @jencompgeek
            Email: jhickey@vmware.com


              2
Saturday, October 20, 2012
Cloud Foundry Big Picture

                                                                                                .js



                                       Ap
                                          p                                                           Private




                                                                                           ce
                                              lic
                                                                                                      Clouds




                                                                                          rfa
                                                at
                                                  io




                                                                                          te
                                                        n
                             Data Services




                                                                                        In
                                                        Se




                                                                                    er
                                                                                               Public
                                                           r




                                                                                   vid
                                                            vic

                                                                                               Clouds




                                                                                    o
                                                                e
                                               Msg




                                                                                 Pr
                                             Services
                                                               In
                                                                 te




                                                                            ud
                                                                    rfa




                                                                             o
                                                                                 Micro
                                                                          Cl
                                                                     ce


                                                         Other
                                                        Services
                                                                             Cloud Foundry
               Apache2 license
              3
Saturday, October 20, 2012
Core Runtimes and Frameworks
        • Java
              –Spring
              –Grails
              –Lift
              –Play
        • Ruby
              –Rails
              –Sinatra
              –Rack
        • Node.js
              4
Saturday, October 20, 2012
Community and partners contributions
        • Python
              –Django
              –WSGI
        • Erlang OTP/Rebar
        • PHP
        • Perl
        • .Net
              –On Iron Foundry


              5
Saturday, October 20, 2012
The Platinum Rule


          Treat each framework
          the way it wants to be treated!




              6
Saturday, October 20, 2012
Common Framework Support
        • Command-line for application management
              –Create apps and services
              –Update bindings, memory etc.
              –Scale instances
        • Access service and app info through environment variables
              –Service host, port, credentials
              –App ip and port
        • A runtime library
              –Connect to services
              –Retrieve app info
              7
Saturday, October 20, 2012
Common Framework Support
        • Auto-reconfiguration for typical apps
        • Access to services through Caldecott
              –Creates tunnel for local clients
              –Mysql, Mongo, Redis CLIs, etc
        • Manifest support




              8
Saturday, October 20, 2012
This Looks Great! But....



                             My App Doesn’t Use Any of These Frameworks!




              9
Saturday, October 20, 2012
Standalone: The “no framework” framework
        • Cloud Foundry now supports standalone applications!
        • Choose a runtime and provide a start command
                $ vmc push myapp
                Detected a Standalone Application, is this correct? [Yn]:
                1: java
                2: node
                3: ruby18
              – 4: ruby19
                Select Runtime [java]:
                Start Command: java -jar myapp.jar



             10
Saturday, October 20, 2012
Uses of Standalone Applications
        • Async Web Frameworks
        • BYOC: Embedding Jetty or Tomcat
        • Distributed polyglot applications
        • Workers




             11
Saturday, October 20, 2012
Call Me Maybe?
        • New frameworks are concurrent, asynchronous, event-
          driven
              –C10K
              –Thread per request/response isn’t going to cut it
        • Single thread to handle multiple connections
              –Callbacks
        • Most use Netty for NIO
        • Some examples
              –vert.x, Blue Eyes, Spray, Unfiltered, Finagle

             12
Saturday, October 20, 2012
vert.x - Asynchronous, Event-Driven Java




             13
Saturday, October 20, 2012
SockJS - WebSocket Emulation
        • Cloud Foundry does not (yet) support WebSocket
        • SockJS emulates WebSocket
              –Provides low latency, full duplex, cross-domain communication
               channel between browser and web server
        • Available for Node.js and vert.x
              –Also Erlang, Lua (Luvit), Python (Tornado)




             14
Saturday, October 20, 2012
Demo
                      Vert.x with SockJS on Cloud
                      Foundry




Saturday, October 20, 2012
Uses of Standalone Applications
        • Async Web Frameworks
        • BYOC: Embedding Jetty or Tomcat
        • Distributed polyglot applications
        • Workers




             16
Saturday, October 20, 2012
Why BYOC?
        • Framework programming model
              –Unfiltered with Jetty support
        • Outpace the CF engineers
              –Tomcat 7/Servlet 3.0
                     • http://blog.cloudfoundry.org/2012/06/18/deploying-tomcat-7-using-the-
                       standalone-framework/
        • Be cutting-edge
              –Clojure
                     • http://blog.cloudfoundry.org/2012/09/25/experimental-clojure-support-
                       in-cloud-foundry/

             17
Saturday, October 20, 2012
More reasons to BYOC....
        • Deploy legacy EJB apps
              –TomEE
        • Customize Tomcat
              –Change logging, server config, etc




             18
Saturday, October 20, 2012
Demo
                      Unfiltered with Jetty on Cloud
                      Foundry




Saturday, October 20, 2012
Uses of Standalone Applications
        • Async Web Frameworks
        • BYOC: Embedding Jetty or Tomcat
        • Distributed polyglot applications
        • Workers




             20
Saturday, October 20, 2012
wgrus-monolithic.war

                                                             @Controller
                                                             StoreFront




                                 Widget             Gadget                 Accounting   Shipping
                             InventoryService   InventoryService            Service     Service




                                                                   RDBMS


             21
Saturday, October 20, 2012
It’s simple to develop but ....
        • Lack of scalability
              –Scale through replication
              –Non-replicable component => nothing can be replicated
              –Can’t scale different parts of the application differently
        • Lack of deployability
              –Deploy it all in one go
              –Increased risk of something breaking




             22
Saturday, October 20, 2012
And....
        • Applications are brittle
              –Store can’t accept orders unless all services are available
              –Failure (e.g. memory leak) in one component can take down
               every other
        • Monolingual
              –Can’t use non-JVM server-side technologies: NodeJS, Rails




             23
Saturday, October 20, 2012
Modern Applications
        • Multiple types of clients
              –Mobile
              –HTML 5
              –Desktop
        • Polyglot applications
              –NodeJS front-end
              –Java/Scala backend
        • Asynchronous
              –RabbitMQ

             24
Saturday, October 20, 2012
And....
        • Polyglot persistence
              –Relational
              –NoSQL
              –NewSQL
        • Social network integration




             25
Saturday, October 20, 2012
Addressing the Scalability
                      Problem




Saturday, October 20, 2012
The App




             27
Saturday, October 20, 2012
Simple Distribution


                              Backend



                                    HTTP


                              Frontend




             28
Saturday, October 20, 2012
Widening Distribution


                                Backend 1



                                      HTTP


                                Frontend 1




             29
Saturday, October 20, 2012
Widening Distribution


                             Backend 2   Backend 1



                                               HTTP


                                         Frontend 1




             29
Saturday, October 20, 2012
Widening Distribution


                             Backend 2   Backend 1    Backend 3



                                               HTTP


                                         Frontend 1




             29
Saturday, October 20, 2012
Widening Distribution


                             Backend 2    Backend 1    Backend 3



                                                HTTP


                             Frontend 2   Frontend 1




             29
Saturday, October 20, 2012
Widening Distribution


                             Backend 2    Backend 1    Backend 3



                                                HTTP


                             Frontend 2   Frontend 1   Frontend 3




             29
Saturday, October 20, 2012
Scaling out in Cloud Foundry




                     vmc instances <app> 5




             30
Saturday, October 20, 2012
Cloud Foundry Manifests


              ---
              applications:
                ./frontend:
                  ...
                  depends-on: ./backend
                ./backend:
                  ...

             31
Saturday, October 20, 2012
wgrus-billing.war
                                                 Accounting
                                                  Service        MySQL




                                          wgrus-inventory

   wgrus-store.war                                Widget
                                              InventoryService
                             StoreFront

                                                  Gadget
                                              InventoryService




                                          wgrus-shipping

                                                   Shipping
                                                   Service

             32
Saturday, October 20, 2012
Demo
                      Distributed polyglot WGRUS




Saturday, October 20, 2012
Scaling out through Akka
        • Remote actors
              –Location transparent and distributable by design
              –Netty based in Akka 2.0
              –Needs cluster-like management




             34
Saturday, October 20, 2012
Remote Actors and Routing

                                   Backend 1    Backend 2

                                     Netty        Netty
               173.136.3.4:59807
               173.14.13.3:57895




                                     Router       Router
                                   Frontend 1   Frontend 2


             35
Saturday, October 20, 2012
Akka: Messaging based remoting

                             Backend 2    Backend 1    Backend 3




                                           AMQP/
                                           Redis




                             Frontend 2   Frontend 1   Frontend 3


             36
Saturday, October 20, 2012
Demo
                      WGRUS with Akka




Saturday, October 20, 2012
Widening Distribution: Messaging Middleware

                             Backend 2    Backend 1    Backend 3




                             Frontend 2   Frontend 1   Frontend 3


             38
Saturday, October 20, 2012
wgrus-billing

                                                           Accounting
                                                            Service        MySQL




                                                    wgrus-inventory

   wgrus-store.war                                          Widget
                                                        InventoryService
                                          Message
                             StoreFront    Broker


                                                            Gadget
                                                        InventoryService




                                                     wgrus-shipping

                                                         Shipping
                                                         Service

             39
Saturday, October 20, 2012
Spring Integration
        • High-level of abstraction for building message based
          applications
        • Implements EAI patterns
        • Provides plumbing for exchanging messages between
          application components
        • Promotes loosely coupled components
        • Integrates with external messaging infrastructure: JMS,
          AMQP, HTTP, Email, File transfer


             40
Saturday, October 20, 2012
Spring Integration Concepts
        • Message channel
              –Virtual pipe connecting producer and consumer
        • Message endpoints
              –The filter of a pipes-and-filter architecture
              –Read from and/or write to channel




             41
Saturday, October 20, 2012
Spring Integration Endpoints
        • Endpoint types
              –Transformer
              –Filter
              –Router
              –Splitter
              –Aggregator
              –ServiceActivator
              –Inbound channel adapter - read from external source, writes to
               channel
              –Outbound channel adapter - read from channel write to external
               destination
             42
Saturday, October 20, 2012
Demo
                      WGRUS with Spring Integration




Saturday, October 20, 2012
Uses of Standalone Applications
        • Async Web Frameworks
        • BYOC: Embedding Jetty or Tomcat
        • Distributed polyglot applications
        • Workers




             44
Saturday, October 20, 2012
Get to Work!
        • Update search indexes!
        • Email your users!
        • Backup your data!
        • Upload new data from external storage!




             45
Saturday, October 20, 2012
Polling for Tweets with Spring Integration
            <int-twitter:search-inbound-channel-adapter id="twitter" query="cloud">
                <int:poller fixed-rate="5000" max-messages-per-poll="10"/>
            </int-twitter:search-inbound-channel-adapter>

        ! <int:transformer input-channel="twitter" expression="payload.fromUser + ': ' + payload.text" output-
        channel="rabbit"/>

        !     <int-amqp:outbound-channel-adapter id="rabbit" exchange-name="tweets"/>

        !     <rabbit:fanout-exchange name="tweets" durable="false"/>
        !     <rabbit:admin connection-factory="rabbitConnectionFactory"/>
        !     <rabbit:template id="amqpTemplate" connection-factory="rabbitConnectionFactory"/>

        !     <beans profile="default">
        !     ! <rabbit:connection-factory id="rabbitConnectionFactory"/>
        !     </beans>

        !     <beans profile="cloud">
        !     ! <cloud:rabbit-connection-factory id="rabbitConnectionFactory"/>
        !     </beans>

             46
Saturday, October 20, 2012
Batch Processing with Spring Batch




             47
Saturday, October 20, 2012
Spring Batch
        • Supports Batch API...
              –Jobs have Steps
              –Steps have Readers, and optional Processors and Writers
                     • Readers read data
                     • Processors process data coming into them, optionally transforming it.
                       Optional.
                     • Writers write data out




             48
Saturday, October 20, 2012
Demo
                      Spring Batch Working it on Cloud
                      Foundry




Saturday, October 20, 2012
Practical Tips

                      Packaging Your App



Saturday, October 20, 2012
Maven Appassembler
        • Creates start script and packages all deps in repo dir
        • vmc push --path=target/appassembler
              –Start command “bin/<scriptname>”
              <plugin>
                  <groupId>org.codehaus.mojo</groupId>
                  !    <artifactId>appassembler-maven-plugin</artifactId>
              !   !    <version>1.1.1</version>
              !   !    <executions>
                  !    !    <execution>
                  !    !    !    <phase>package</phase>
              !   !    !    !    <goals>
                  !    !    !    !   <goal>assemble</goal>
              !   !    !    !    </goals>
              !   !    !    !    <configuration>
                  !    !    !    !   <assembledirectory>target</assembledirectory>
              !   !    !    !    !   <programs>
                  !    !    !    !   !    <program>
                  !    !    !    !   !    !   <mainClass>org.springsource.samples.twitter.Demo</mainClass>
              !   !    !    !    !   !    </program>

             51
Saturday, October 20, 2012
Gradle
        • Use the application plugin
              –Run “gradle installApp”
        • Creates start script and packages all deps in lib dir
        • vmc push --path=build/install/<appname>
              –Start command “bin/<scriptname>”


              apply plugin: 'application'

              mainClassName = "org.springsource.samples.twitter.Demo"




             52
Saturday, October 20, 2012
SBT
        • Use sbt-package-dist
        • Creates a zip of all code and deps
        • vmc push --path=dist/appname/<zipname>.zip
              –Start command “java $JAVA_OPTS -jar <main>.jar”
              plugins.sbt:
              addSbtPlugin("com.twitter" %% "sbt-package-dist" % "1.0.0")

              resolvers += "twitter-repo" at "http://maven.twttr.com"

              build.sbt:
              import com.twitter.sbt._
              packageDistZipName := "bitshow.zip"

              mainClass in Compile := Some("bitshow.Server")

             53
Saturday, October 20, 2012
Eclipse Plugin
        • Does the packaging for you
        • Deploy and debug standalone Java apps
              –Including Scala and Groovy
        • Caldecott support
              –Tunnel to all services




             54
Saturday, October 20, 2012
Practical Tips

                      Accessing Services



Saturday, October 20, 2012
cloudfoundry-runtime
        • Programmatic creation of service connection factories
              –Using ServiceCreator and ServiceInfo classes
        • CloudEnvironment class
              –Access cloud properties
              –Access service info
              – No JSON parsing
        • Get from the Spring milestone maven repo




             56
Saturday, October 20, 2012
Using ServiceCreator in Spring Applications
                   //Provides access to CF service and application env info
                   CloudEnvironment environment = new CloudEnvironment();
                   ! !
                   //Retrieve env info for bound service named "mysqlService"
                   RdbmsServiceInfo mysqlSvc =
                       environment.getServiceInfo("mysqlService", RdbmsServiceInfo.class);
                   ! !
                   //create a DataSource bound to the service
                   RdbmsServiceCreator dataSourceCreator = new RdbmsServiceCreator();
                   DataSource dataSource = dataSourceCreator.createService(mysqlSvc);




             57
Saturday, October 20, 2012
Using ServiceInfo for all Java Apps
                    //Provides access to CF service and application env info
                    CloudEnvironment environment = new CloudEnvironment();
                    ! !
                    //Retrieve env info for bound service named "mongoService"
                    MongoServiceInfo mongoSvc =
                        environment.getServiceInfo("mongoService", MongoServiceInfo.class);
                    ! !
                    //create a Mongo DB bound to the service
                    Mongo mongoDB = new Mongo(mongoSvc.getHost(), mongoSvc.getPort());




             58
Saturday, October 20, 2012
More Practical Tips...
        • Use VCAP_APP_HOST and VCAP_APP_PORT env vars
              –If not using cloudfoundry-runtime lib
        • Don’t assign your app a URL unless you plan to bind to the
          web port
              –CF will think your app did not start
        • Keep It Alive!
              –CF will attempt to restart your app if it dies
        • Use $JAVA_OPTS in your Java commands
              –Sets Heap appropriately
              –Allows debug on local clouds
             59
Saturday, October 20, 2012
Key Takeaway
            Endless possibilities with standalone apps on Cloud Foundry




             60
Saturday, October 20, 2012
Demos
        • Vert.x with SockJS
              –https://github.com/cloudfoundry-samples/vertx-socks-sample
        • Unfiltered with Jetty
              –https://github.com/cloudfoundry-samples/cf-unfiltered-sample
        • WGRUS
              –https://github.com/cloudfoundry-samples/wgrus
        • Spring Batch Workers
              –https://github.com/cloudfoundry-samples/spring-batch-tweet-
               workers

             61
Saturday, October 20, 2012
Questions?




Saturday, October 20, 2012

Mais conteúdo relacionado

Destaque

Destaque (12)

Building Enterprise Applications on Google Cloud Platform Cloud Computing Exp...
Building Enterprise Applications on Google Cloud Platform Cloud Computing Exp...Building Enterprise Applications on Google Cloud Platform Cloud Computing Exp...
Building Enterprise Applications on Google Cloud Platform Cloud Computing Exp...
 
Shakr - Container CI/CD with Google Cloud Platform
Shakr - Container CI/CD with Google Cloud PlatformShakr - Container CI/CD with Google Cloud Platform
Shakr - Container CI/CD with Google Cloud Platform
 
Google Cloud Platform Empowers TensorFlow and Machine Learning
Google Cloud Platform Empowers TensorFlow and Machine LearningGoogle Cloud Platform Empowers TensorFlow and Machine Learning
Google Cloud Platform Empowers TensorFlow and Machine Learning
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
Understanding cloud with Google Cloud Platform
Understanding cloud with Google Cloud PlatformUnderstanding cloud with Google Cloud Platform
Understanding cloud with Google Cloud Platform
 
Google Cloud for Developers - Devfest Manila
Google Cloud for Developers - Devfest ManilaGoogle Cloud for Developers - Devfest Manila
Google Cloud for Developers - Devfest Manila
 
Introduction to Google Cloud Platform
Introduction to Google Cloud PlatformIntroduction to Google Cloud Platform
Introduction to Google Cloud Platform
 
Andreas Tschas - Pioneers - Building Startup Marketplaces in Europe & Asia - ...
Andreas Tschas - Pioneers - Building Startup Marketplaces in Europe & Asia - ...Andreas Tschas - Pioneers - Building Startup Marketplaces in Europe & Asia - ...
Andreas Tschas - Pioneers - Building Startup Marketplaces in Europe & Asia - ...
 
A Tour of Google Cloud Platform
A Tour of Google Cloud PlatformA Tour of Google Cloud Platform
A Tour of Google Cloud Platform
 
Cloud Price Comparison - AWS vs Azure vs Google
Cloud Price Comparison - AWS vs Azure vs GoogleCloud Price Comparison - AWS vs Azure vs Google
Cloud Price Comparison - AWS vs Azure vs Google
 
[Infographic] How will Internet of Things (IoT) change the world as we know it?
[Infographic] How will Internet of Things (IoT) change the world as we know it?[Infographic] How will Internet of Things (IoT) change the world as we know it?
[Infographic] How will Internet of Things (IoT) change the world as we know it?
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and Archives
 

Semelhante a Thinking Outside the Container: Deploying Standalone Apps to Cloud Foundry

Cloud Foundry Architecture and Overview
Cloud Foundry Architecture and OverviewCloud Foundry Architecture and Overview
Cloud Foundry Architecture and Overview
rajdeep
 
PaaS Parade - Cloud Foundry
PaaS Parade - Cloud FoundryPaaS Parade - Cloud Foundry
PaaS Parade - Cloud Foundry
martinlippert
 
Cloud Foundry Introduction - Canada - October 2012
Cloud Foundry Introduction - Canada - October 2012Cloud Foundry Introduction - Canada - October 2012
Cloud Foundry Introduction - Canada - October 2012
Patrick Chanezon
 
Portrait of the Developer As "The Artist" - English Version
Portrait of the Developer As "The Artist" - English VersionPortrait of the Developer As "The Artist" - English Version
Portrait of the Developer As "The Artist" - English Version
Patrick Chanezon
 
Cloud Foundry - A Lightning Introduction
Cloud Foundry - A Lightning IntroductionCloud Foundry - A Lightning Introduction
Cloud Foundry - A Lightning Introduction
Andy Piper
 
Building an Open Cloud Ecosystem with Cloud Foundry
Building an Open Cloud Ecosystem with Cloud FoundryBuilding an Open Cloud Ecosystem with Cloud Foundry
Building an Open Cloud Ecosystem with Cloud Foundry
Andy Piper
 
Portrait of the Developer as the Artist - OpenTour Sofia
Portrait of the Developer as the Artist - OpenTour SofiaPortrait of the Developer as the Artist - OpenTour Sofia
Portrait of the Developer as the Artist - OpenTour Sofia
Patrick Chanezon
 
Market Research Report : Cloud Computing Market in India 2010
Market Research Report : Cloud Computing Market in India 2010Market Research Report : Cloud Computing Market in India 2010
Market Research Report : Cloud Computing Market in India 2010
Netscribes, Inc.
 

Semelhante a Thinking Outside the Container: Deploying Standalone Apps to Cloud Foundry (20)

Cloud Foundry Architecture and Overview
Cloud Foundry Architecture and OverviewCloud Foundry Architecture and Overview
Cloud Foundry Architecture and Overview
 
Portrait of the developer as The Artist - SpringOne India 2012
Portrait of the developer as The Artist - SpringOne India 2012Portrait of the developer as The Artist - SpringOne India 2012
Portrait of the developer as The Artist - SpringOne India 2012
 
Hands On CloudFoundry
Hands On CloudFoundryHands On CloudFoundry
Hands On CloudFoundry
 
PaaS Parade - Cloud Foundry
PaaS Parade - Cloud FoundryPaaS Parade - Cloud Foundry
PaaS Parade - Cloud Foundry
 
Cloud Foundry bootcamp at ContributingCode
Cloud Foundry bootcamp at ContributingCodeCloud Foundry bootcamp at ContributingCode
Cloud Foundry bootcamp at ContributingCode
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDB
 
RubyWorld 2011
RubyWorld 2011RubyWorld 2011
RubyWorld 2011
 
Cloud Foundry Introduction - Canada - October 2012
Cloud Foundry Introduction - Canada - October 2012Cloud Foundry Introduction - Canada - October 2012
Cloud Foundry Introduction - Canada - October 2012
 
Cloud Foundry for Java devs
Cloud Foundry for Java devsCloud Foundry for Java devs
Cloud Foundry for Java devs
 
Portrait of the Developer As "The Artist" - English Version
Portrait of the Developer As "The Artist" - English VersionPortrait of the Developer As "The Artist" - English Version
Portrait of the Developer As "The Artist" - English Version
 
Cloud Foundry: Inside the Machine
Cloud Foundry: Inside the MachineCloud Foundry: Inside the Machine
Cloud Foundry: Inside the Machine
 
Cloud Foundry - A Lightning Introduction
Cloud Foundry - A Lightning IntroductionCloud Foundry - A Lightning Introduction
Cloud Foundry - A Lightning Introduction
 
Cloud foundry - the building of the open paas presentation
Cloud foundry - the building of the open paas presentationCloud foundry - the building of the open paas presentation
Cloud foundry - the building of the open paas presentation
 
OSCON 2011
OSCON 2011OSCON 2011
OSCON 2011
 
Building an Open Cloud Ecosystem with Cloud Foundry
Building an Open Cloud Ecosystem with Cloud FoundryBuilding an Open Cloud Ecosystem with Cloud Foundry
Building an Open Cloud Ecosystem with Cloud Foundry
 
Portrait of the Developer as the Artist - OpenTour Sofia
Portrait of the Developer as the Artist - OpenTour SofiaPortrait of the Developer as the Artist - OpenTour Sofia
Portrait of the Developer as the Artist - OpenTour Sofia
 
Making a Cleaner Cloud with Open Source
Making a Cleaner Cloud with Open SourceMaking a Cleaner Cloud with Open Source
Making a Cleaner Cloud with Open Source
 
Migrating to Cloud Foundry
Migrating to Cloud FoundryMigrating to Cloud Foundry
Migrating to Cloud Foundry
 
Decomposing Applications for Scalability and Deployability (April 2012)
Decomposing Applications for Scalability and Deployability (April 2012)Decomposing Applications for Scalability and Deployability (April 2012)
Decomposing Applications for Scalability and Deployability (April 2012)
 
Market Research Report : Cloud Computing Market in India 2010
Market Research Report : Cloud Computing Market in India 2010Market Research Report : Cloud Computing Market in India 2010
Market Research Report : Cloud Computing Market in India 2010
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Thinking Outside the Container: Deploying Standalone Apps to Cloud Foundry

  • 1. Thinking Outside the Container: Deploying Standalone Apps to Cloud Foundry Jennifer Hickey © 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission. Saturday, October 20, 2012
  • 2. About Jennifer • Engineer @ Cloud Foundry • Focused on framework support • Long time SpringSource-er • Contributed to many Spring and SpringSource projects • Passionate about increasing developer productivity in the cloud. Contact Info Twitter: @jencompgeek Email: jhickey@vmware.com 2 Saturday, October 20, 2012
  • 3. Cloud Foundry Big Picture .js Ap p Private ce lic Clouds rfa at io te n Data Services In Se er Public r vid vic Clouds o e Msg Pr Services In te ud rfa o Micro Cl ce Other Services Cloud Foundry Apache2 license 3 Saturday, October 20, 2012
  • 4. Core Runtimes and Frameworks • Java –Spring –Grails –Lift –Play • Ruby –Rails –Sinatra –Rack • Node.js 4 Saturday, October 20, 2012
  • 5. Community and partners contributions • Python –Django –WSGI • Erlang OTP/Rebar • PHP • Perl • .Net –On Iron Foundry 5 Saturday, October 20, 2012
  • 6. The Platinum Rule Treat each framework the way it wants to be treated! 6 Saturday, October 20, 2012
  • 7. Common Framework Support • Command-line for application management –Create apps and services –Update bindings, memory etc. –Scale instances • Access service and app info through environment variables –Service host, port, credentials –App ip and port • A runtime library –Connect to services –Retrieve app info 7 Saturday, October 20, 2012
  • 8. Common Framework Support • Auto-reconfiguration for typical apps • Access to services through Caldecott –Creates tunnel for local clients –Mysql, Mongo, Redis CLIs, etc • Manifest support 8 Saturday, October 20, 2012
  • 9. This Looks Great! But.... My App Doesn’t Use Any of These Frameworks! 9 Saturday, October 20, 2012
  • 10. Standalone: The “no framework” framework • Cloud Foundry now supports standalone applications! • Choose a runtime and provide a start command $ vmc push myapp Detected a Standalone Application, is this correct? [Yn]: 1: java 2: node 3: ruby18 – 4: ruby19 Select Runtime [java]: Start Command: java -jar myapp.jar 10 Saturday, October 20, 2012
  • 11. Uses of Standalone Applications • Async Web Frameworks • BYOC: Embedding Jetty or Tomcat • Distributed polyglot applications • Workers 11 Saturday, October 20, 2012
  • 12. Call Me Maybe? • New frameworks are concurrent, asynchronous, event- driven –C10K –Thread per request/response isn’t going to cut it • Single thread to handle multiple connections –Callbacks • Most use Netty for NIO • Some examples –vert.x, Blue Eyes, Spray, Unfiltered, Finagle 12 Saturday, October 20, 2012
  • 13. vert.x - Asynchronous, Event-Driven Java 13 Saturday, October 20, 2012
  • 14. SockJS - WebSocket Emulation • Cloud Foundry does not (yet) support WebSocket • SockJS emulates WebSocket –Provides low latency, full duplex, cross-domain communication channel between browser and web server • Available for Node.js and vert.x –Also Erlang, Lua (Luvit), Python (Tornado) 14 Saturday, October 20, 2012
  • 15. Demo Vert.x with SockJS on Cloud Foundry Saturday, October 20, 2012
  • 16. Uses of Standalone Applications • Async Web Frameworks • BYOC: Embedding Jetty or Tomcat • Distributed polyglot applications • Workers 16 Saturday, October 20, 2012
  • 17. Why BYOC? • Framework programming model –Unfiltered with Jetty support • Outpace the CF engineers –Tomcat 7/Servlet 3.0 • http://blog.cloudfoundry.org/2012/06/18/deploying-tomcat-7-using-the- standalone-framework/ • Be cutting-edge –Clojure • http://blog.cloudfoundry.org/2012/09/25/experimental-clojure-support- in-cloud-foundry/ 17 Saturday, October 20, 2012
  • 18. More reasons to BYOC.... • Deploy legacy EJB apps –TomEE • Customize Tomcat –Change logging, server config, etc 18 Saturday, October 20, 2012
  • 19. Demo Unfiltered with Jetty on Cloud Foundry Saturday, October 20, 2012
  • 20. Uses of Standalone Applications • Async Web Frameworks • BYOC: Embedding Jetty or Tomcat • Distributed polyglot applications • Workers 20 Saturday, October 20, 2012
  • 21. wgrus-monolithic.war @Controller StoreFront Widget Gadget Accounting Shipping InventoryService InventoryService Service Service RDBMS 21 Saturday, October 20, 2012
  • 22. It’s simple to develop but .... • Lack of scalability –Scale through replication –Non-replicable component => nothing can be replicated –Can’t scale different parts of the application differently • Lack of deployability –Deploy it all in one go –Increased risk of something breaking 22 Saturday, October 20, 2012
  • 23. And.... • Applications are brittle –Store can’t accept orders unless all services are available –Failure (e.g. memory leak) in one component can take down every other • Monolingual –Can’t use non-JVM server-side technologies: NodeJS, Rails 23 Saturday, October 20, 2012
  • 24. Modern Applications • Multiple types of clients –Mobile –HTML 5 –Desktop • Polyglot applications –NodeJS front-end –Java/Scala backend • Asynchronous –RabbitMQ 24 Saturday, October 20, 2012
  • 25. And.... • Polyglot persistence –Relational –NoSQL –NewSQL • Social network integration 25 Saturday, October 20, 2012
  • 26. Addressing the Scalability Problem Saturday, October 20, 2012
  • 27. The App 27 Saturday, October 20, 2012
  • 28. Simple Distribution Backend HTTP Frontend 28 Saturday, October 20, 2012
  • 29. Widening Distribution Backend 1 HTTP Frontend 1 29 Saturday, October 20, 2012
  • 30. Widening Distribution Backend 2 Backend 1 HTTP Frontend 1 29 Saturday, October 20, 2012
  • 31. Widening Distribution Backend 2 Backend 1 Backend 3 HTTP Frontend 1 29 Saturday, October 20, 2012
  • 32. Widening Distribution Backend 2 Backend 1 Backend 3 HTTP Frontend 2 Frontend 1 29 Saturday, October 20, 2012
  • 33. Widening Distribution Backend 2 Backend 1 Backend 3 HTTP Frontend 2 Frontend 1 Frontend 3 29 Saturday, October 20, 2012
  • 34. Scaling out in Cloud Foundry vmc instances <app> 5 30 Saturday, October 20, 2012
  • 35. Cloud Foundry Manifests --- applications: ./frontend: ... depends-on: ./backend ./backend: ... 31 Saturday, October 20, 2012
  • 36. wgrus-billing.war Accounting Service MySQL wgrus-inventory wgrus-store.war Widget InventoryService StoreFront Gadget InventoryService wgrus-shipping Shipping Service 32 Saturday, October 20, 2012
  • 37. Demo Distributed polyglot WGRUS Saturday, October 20, 2012
  • 38. Scaling out through Akka • Remote actors –Location transparent and distributable by design –Netty based in Akka 2.0 –Needs cluster-like management 34 Saturday, October 20, 2012
  • 39. Remote Actors and Routing Backend 1 Backend 2 Netty Netty 173.136.3.4:59807 173.14.13.3:57895 Router Router Frontend 1 Frontend 2 35 Saturday, October 20, 2012
  • 40. Akka: Messaging based remoting Backend 2 Backend 1 Backend 3 AMQP/ Redis Frontend 2 Frontend 1 Frontend 3 36 Saturday, October 20, 2012
  • 41. Demo WGRUS with Akka Saturday, October 20, 2012
  • 42. Widening Distribution: Messaging Middleware Backend 2 Backend 1 Backend 3 Frontend 2 Frontend 1 Frontend 3 38 Saturday, October 20, 2012
  • 43. wgrus-billing Accounting Service MySQL wgrus-inventory wgrus-store.war Widget InventoryService Message StoreFront Broker Gadget InventoryService wgrus-shipping Shipping Service 39 Saturday, October 20, 2012
  • 44. Spring Integration • High-level of abstraction for building message based applications • Implements EAI patterns • Provides plumbing for exchanging messages between application components • Promotes loosely coupled components • Integrates with external messaging infrastructure: JMS, AMQP, HTTP, Email, File transfer 40 Saturday, October 20, 2012
  • 45. Spring Integration Concepts • Message channel –Virtual pipe connecting producer and consumer • Message endpoints –The filter of a pipes-and-filter architecture –Read from and/or write to channel 41 Saturday, October 20, 2012
  • 46. Spring Integration Endpoints • Endpoint types –Transformer –Filter –Router –Splitter –Aggregator –ServiceActivator –Inbound channel adapter - read from external source, writes to channel –Outbound channel adapter - read from channel write to external destination 42 Saturday, October 20, 2012
  • 47. Demo WGRUS with Spring Integration Saturday, October 20, 2012
  • 48. Uses of Standalone Applications • Async Web Frameworks • BYOC: Embedding Jetty or Tomcat • Distributed polyglot applications • Workers 44 Saturday, October 20, 2012
  • 49. Get to Work! • Update search indexes! • Email your users! • Backup your data! • Upload new data from external storage! 45 Saturday, October 20, 2012
  • 50. Polling for Tweets with Spring Integration <int-twitter:search-inbound-channel-adapter id="twitter" query="cloud"> <int:poller fixed-rate="5000" max-messages-per-poll="10"/> </int-twitter:search-inbound-channel-adapter> ! <int:transformer input-channel="twitter" expression="payload.fromUser + ': ' + payload.text" output- channel="rabbit"/> ! <int-amqp:outbound-channel-adapter id="rabbit" exchange-name="tweets"/> ! <rabbit:fanout-exchange name="tweets" durable="false"/> ! <rabbit:admin connection-factory="rabbitConnectionFactory"/> ! <rabbit:template id="amqpTemplate" connection-factory="rabbitConnectionFactory"/> ! <beans profile="default"> ! ! <rabbit:connection-factory id="rabbitConnectionFactory"/> ! </beans> ! <beans profile="cloud"> ! ! <cloud:rabbit-connection-factory id="rabbitConnectionFactory"/> ! </beans> 46 Saturday, October 20, 2012
  • 51. Batch Processing with Spring Batch 47 Saturday, October 20, 2012
  • 52. Spring Batch • Supports Batch API... –Jobs have Steps –Steps have Readers, and optional Processors and Writers • Readers read data • Processors process data coming into them, optionally transforming it. Optional. • Writers write data out 48 Saturday, October 20, 2012
  • 53. Demo Spring Batch Working it on Cloud Foundry Saturday, October 20, 2012
  • 54. Practical Tips Packaging Your App Saturday, October 20, 2012
  • 55. Maven Appassembler • Creates start script and packages all deps in repo dir • vmc push --path=target/appassembler –Start command “bin/<scriptname>” <plugin> <groupId>org.codehaus.mojo</groupId> ! <artifactId>appassembler-maven-plugin</artifactId> ! ! <version>1.1.1</version> ! ! <executions> ! ! <execution> ! ! ! <phase>package</phase> ! ! ! ! <goals> ! ! ! ! <goal>assemble</goal> ! ! ! ! </goals> ! ! ! ! <configuration> ! ! ! ! <assembledirectory>target</assembledirectory> ! ! ! ! ! <programs> ! ! ! ! ! <program> ! ! ! ! ! ! <mainClass>org.springsource.samples.twitter.Demo</mainClass> ! ! ! ! ! ! </program> 51 Saturday, October 20, 2012
  • 56. Gradle • Use the application plugin –Run “gradle installApp” • Creates start script and packages all deps in lib dir • vmc push --path=build/install/<appname> –Start command “bin/<scriptname>” apply plugin: 'application' mainClassName = "org.springsource.samples.twitter.Demo" 52 Saturday, October 20, 2012
  • 57. SBT • Use sbt-package-dist • Creates a zip of all code and deps • vmc push --path=dist/appname/<zipname>.zip –Start command “java $JAVA_OPTS -jar <main>.jar” plugins.sbt: addSbtPlugin("com.twitter" %% "sbt-package-dist" % "1.0.0") resolvers += "twitter-repo" at "http://maven.twttr.com" build.sbt: import com.twitter.sbt._ packageDistZipName := "bitshow.zip" mainClass in Compile := Some("bitshow.Server") 53 Saturday, October 20, 2012
  • 58. Eclipse Plugin • Does the packaging for you • Deploy and debug standalone Java apps –Including Scala and Groovy • Caldecott support –Tunnel to all services 54 Saturday, October 20, 2012
  • 59. Practical Tips Accessing Services Saturday, October 20, 2012
  • 60. cloudfoundry-runtime • Programmatic creation of service connection factories –Using ServiceCreator and ServiceInfo classes • CloudEnvironment class –Access cloud properties –Access service info – No JSON parsing • Get from the Spring milestone maven repo 56 Saturday, October 20, 2012
  • 61. Using ServiceCreator in Spring Applications //Provides access to CF service and application env info CloudEnvironment environment = new CloudEnvironment(); ! ! //Retrieve env info for bound service named "mysqlService" RdbmsServiceInfo mysqlSvc = environment.getServiceInfo("mysqlService", RdbmsServiceInfo.class); ! ! //create a DataSource bound to the service RdbmsServiceCreator dataSourceCreator = new RdbmsServiceCreator(); DataSource dataSource = dataSourceCreator.createService(mysqlSvc); 57 Saturday, October 20, 2012
  • 62. Using ServiceInfo for all Java Apps //Provides access to CF service and application env info CloudEnvironment environment = new CloudEnvironment(); ! ! //Retrieve env info for bound service named "mongoService" MongoServiceInfo mongoSvc = environment.getServiceInfo("mongoService", MongoServiceInfo.class); ! ! //create a Mongo DB bound to the service Mongo mongoDB = new Mongo(mongoSvc.getHost(), mongoSvc.getPort()); 58 Saturday, October 20, 2012
  • 63. More Practical Tips... • Use VCAP_APP_HOST and VCAP_APP_PORT env vars –If not using cloudfoundry-runtime lib • Don’t assign your app a URL unless you plan to bind to the web port –CF will think your app did not start • Keep It Alive! –CF will attempt to restart your app if it dies • Use $JAVA_OPTS in your Java commands –Sets Heap appropriately –Allows debug on local clouds 59 Saturday, October 20, 2012
  • 64. Key Takeaway Endless possibilities with standalone apps on Cloud Foundry 60 Saturday, October 20, 2012
  • 65. Demos • Vert.x with SockJS –https://github.com/cloudfoundry-samples/vertx-socks-sample • Unfiltered with Jetty –https://github.com/cloudfoundry-samples/cf-unfiltered-sample • WGRUS –https://github.com/cloudfoundry-samples/wgrus • Spring Batch Workers –https://github.com/cloudfoundry-samples/spring-batch-tweet- workers 61 Saturday, October 20, 2012