Developing polyglot applications
      on Cloud Foundry
Chris Richardson


Author of POJOs in Action
Founder of the original CloudFoundry.com
  @crichardson
crichardson@vmware.com
http://plainoldobjects.com/
Presentation goal

  Modular, polyglot applications:
      what, why and how?


  How Cloud Foundry simplifies
their development and deployment
About Chris
(About Chris)
About Chris()
About Chris
About Chris




http://www.theregister.co.uk/2009/08/19/
       springsource_cloud_foundry/
vmc push About-Chris

   Developer Advocate for
     CloudFoundry.com



Signup at http://cloudfoundry.com
Agenda


• The   (sometimes evil) monolith

• Refactoring   to a modular, polyglot architecture

• Deploying   modular, polyglot applications
Let’s imagine you are building an
     e-commerce application
Traditional web application
                  architecture
                             WAR



                                    StoreFrontUI


                                     Accounting
                                      Service

                                                      MySQL
Browser        Apache                                 Database
                                   InventoryService




Simple to                              Shipping
                                       Service


     develop
     test               Tomcat
     deploy
     scale
But there are problems
Users expect a rich, dynamic and
     interactive experience
                                                                   h
                                                                oug
                                                          d   en
                         HTTP Request
                                                        oo
                                                    ’t g
   Browser
                                             e   isn       Java Web Application
                         HTML/Javascript
                                      ec tur
                                    it
                               ar ch
                        e UI
                 s   tyl
             Old


             Real-time web ≅ NodeJS
Limitations of relational
                    databases

• Scalability

• Distribution

• Schema   updates

• O/R   impedance mismatch

• Handling   semi-structured data
Monolithic architecture
          =
      Problems
Intimidates developers
Obstacle to frequent
                    deployments
•   Need to redeploy everything to change one component

•   Increases risk of failure, e.g. interrupts background jobs



                                 Fear of change



•   Extensive test cycle
•   Updates will happen less often, e.g. Makes A/B testing UI really difficult
Overloads your IDE and container




      Slows down development
Obstacle to scaling development
                            But the
      I want to update
                         backend is not
           the UI
                          working yet!




   Lots of coordination and
    communication required
Requires long-term
 commitment to a
 technology stack
Agenda

• The   (sometimes evil) monolith

• Refactoring   to a modular, polyglot architecture

  • Decomposing     applications into services

  • Using   NoSQL

  • Presentation   layer design

• Deploying   modular, polyglot applications
The scale cube


Y axis -
functional
decomposition




                                                           ila g
                                                       sim nin
Scale by




                                                              r
                                                ing ing tio
splitting




                                              th litt r ti
                                                 sp pa
different things



                                              by data

                                                   s
                                           ale -
                                         Sc is
                                             ax
                                           Z

                   X axis - horizontal
                      duplication
Y-axis scaling - application level
          WAR



                 StoreFrontUI


                  Accounting
                   Service


                InventoryService



                    Shipping
                    Service
Y-axis scaling - application level
                                                       accounting application

                                                                     Accounting
                                                                      Service




Store front web application                              inventory application



             StoreFrontUI                                        InventoryService




                                                       shipping application


                                                                      Shipping
                                                                      Service




  Apply X axis cloning and/or Z axis partitioning to each service
Drawbacks of Y-axis splits


• Complexity

• Partitioned   databases and transaction management

• Deciding   when to use this approach
But there are many benefits

• Scales
       development: develop, deploy and scale each service
 independently

• Less   for each developer to learn

• Doesn’t   overload IDE or container

• Improves   fault isolation

• Eliminates   long-term commitment to a single technology stack
Two levels of architecture
                         System-level

Services
Inter-service glue: interfaces and communication mechanisms
Slow changing

                         Service-level

Internal architecture of each service
Each service can use a different technology stack
Pick the best tool for the job
Rapidly evolving - regularly rewrite
Modular, polyglot,
  applications
Inter-service communication
                options
• Transports: Synchronous   HTTP      asynchronous AMQP

• Formats: JSON, XML, Protocol   Buffers, Thrift, ...

   Asynchronous is preferred but REST
                is fine
 JSON is fashionable but binary format
            is more efficient
Asynchronous message-based communication
                                        accounting application

                                            Accounting
                                             Service




storefront web application               inventory application

                             RabbitMQ
     StoreFrontUI            (Message    InventoryService
                                                                 MySQL
                              Broker)




                                         shipping application



                                         ShippingService
Agenda

• The   (sometimes evil) monolith

• Refactoring   to a modular, polyglot architecture

  • Decomposing     applications into services

  • Using   NoSQL

  • Presentation   layer design

• Deploying   modular, polyglot applications
Solution: Use NoSQL

 Benefits                  Drawbacks

• Higher   performance   • Limited   transactions

• Higher   scalability   • Limited   querying

• Richer   data-model    • Relaxed   consistency

• Schema-less            • Unconstrained    data
Example NoSQL Databases
Database                       Key features

Cassandra   Extensible column store, very scalable, distributed

 Neo4j                       Graph database
                    Document-oriented, fast, scalable
MongoDB

  Redis                 Key-value store, very fast

      http://nosql-database.org/ lists 122+ NoSQL
                        databases
NoSQL and the scale cube




                                    nin a ing
                                itio dr rd
                             r t an ha
                           pa ss s
                               Ca DB


                                       g
                                   go
                                on
                             M
   MongoDB replica sets
   Cassandra replication
The future is polyglot




 IEEE Software Sept/October 2010 - Debasish Ghosh / Twitter @debasishg
Polyglot persistence architecture
                                            accounting application

                                                Accounting
                                                 Service             MySQL




storefront web application                   inventory application

                               RabbitMQ
     StoreFrontUI              (Message      InventoryService        Redis
                                Broker)




                                             shipping application



                                             ShippingService         Mongo
Agenda

• The   (sometimes evil) monolith

• Refactoring   to a modular, polyglot architecture

  • Decomposing     applications into services

  • Using   NoSQL

  • Presentation   layer design

• Deploying   modular, polyglot applications
Modular application




Choice of presentation layer
        technology
NodeJS is the fashionable
      technology
Why NodeJS?
• Familiar   JavaScript

• High-performance, scalable   event-driven, non-blocking I/O
 model

• Over   13,000 17,000 modules developed by the community

• ManyJavaScript client frameworks have a NodeJS
 counterpart, e.g. socket.io and SockJS
Why not NodeJS?




           a.k.a. callback hell
A modern web application

              REST       Node JS     Service 1
Browser


                                     Service 2
              Events
 HTML 5                  Server
Application            Application
Socket.io              Socket.io
  client                server          ...
NodeJS as a mediator

REST                 REST
                             Service




          Node JS


Events               AMQP              AMQP
         socket.io          RabbitMQ          Service
Socket.io - server-side
var express = require('express')
  , http = require('http')
  , amqp = require(‘amqp’)
  ....;

server.listen(8081);                                       Handle socket.io
...                                                          connection
var amqpCon = amqp.createConnection(...);

io.sockets.on('connection', function (socket) {
                                                                   Republish as
  function amqpMessageHandler(message, headers, deliveryInfo) {   socket.io event
      var m = JSON.parse(message.data.toString());
      socket.emit(‘tick’, m);
   };
   amqpCon.queue(“myQueue”, {},
       function(queue) {                                       Subscribe to AMQP
         queue.bind(“myExchange”, “myBindingKey”);
         queue.subscribe(amqpMessageHandler);
                                                                     queue
   });
});
Socket.io - client-side
<html>
<body>

The event is <span data-bind="text: ticker"></span>

<script src="/socket.io/socket.io.js"></script>
<script src="/knockout-2.0.0.js"></script>
<script src="/clock.js"></script>

</body>                            Bind to model        Connect to
</html>
                                                      socket.io server
              clock.js
var socket = io.connect(location.hostname);

function ClockModel() {
  self.ticker = ko.observable(1);                      Subscribe to tick
  socket.on('tick', function (data) {                       event
   self.ticker(data);
 });
};
                                                         Update model
ko.applyBindings(new ClockModel());
Modular, polyglot architecture




                                                            p,
                                              Native Mobile application          HTML5 mobile application




                                                         lo
                  Desktop Browser

                   StoreUI                           StoreUI                     StoreUI




                                                      ve
                                                   de
Asynchronous,                                         NodeJS




                                                    ?
                                                        NodeJS                                   Javascript
   scalable




                                                  is
                                                      StoreUI
communication




                                               th
                                            te e
                                              w     RabbitMQ




                                              st
                                            oy
                           do
 Spring/Scala                                                                                                 Standalone
web application                     Inventory
                                      Inventory                           Shipping Service                     “headless”

                                          pl
                                     Service                                   Shipping
                                       Service                                                                Spring/Java
      ow


                                                                                                              applications
                                       de
                  Billing Service          Redis Inventory                 Mongo Order
     H




                                             Database                       Database
                                     d
                                an



                     MySQL
                    Customer
                    Database
Agenda

• The   (sometimes evil) monolith

• Refactoring   to a modular, polyglot architecture

• Deploying   modular, polyglot applications

  • Overview    of Cloud Foundry

  • Using   Cloud Foundry

  • Consuming     Cloud Foundry services
The Open
           Platform as a Service

   Deploy and scale polyglot
applications in seconds, without
  locking yourself into a single
              cloud             ible,
                                     pen , Flex
                          Sim ple, O lable
                                   Sca
OSS community




 vFabric
Postgres                            Ap
                                                                       Private	
  
                                                                       Clouds	
  
                                       p
           Data Services
                                      lica
                                         'o
                                           n	
  S


        vFabric
                                                                   Public
                                             erv


      RabbitMQTM
                                                ice



                     Msg Services
                                                                   Clouds
                                                   	
  In
                                                     ter
                                                        fac




                                                               Micro
                                                           e




                                    Other Services
                                                               Clouds
           Additional partners services …
CloudFoundry.COM - Multi-
tenant PaaS operated by VMware
                     CloudFoundry.COM (beta)
   Services
  Runtimes & Frameworks




                          vCenter / vSphere

  Infrastructure
Micro Cloud             –                                 FoundryTM

Industry first downloadable PaaS


      App Instances                               Services




      Open source Platform as a Service project




      A cloud packaged as a VMware Virtual Machine
CloudFoundry.ORG - Vibrant Apache
   2 licensed open-source project
                   CloudFoundry.ORG




                    Your Infrastructure

    Download      Setup                          Deploy Behind
     Code      Environment                BOSH     Firewall
Cloud Foundry: you can trade-off
 Less
        effort vs flexibility Less
         Public PaaS

                                                                ....
                                 .COM


         Private PaaS
Effort                                              ....                  Flexibility


         Custom Private PaaS

                       git clone git://github.com/cloudfoundry/vcap.git

 More                                                                      More
Agenda

• The   (sometimes evil) monolith

• Refactoring   to a modular, polyglot architecture

• Deploying   modular, polyglot applications

  • Overview    of Cloud Foundry

  • Using   Cloud Foundry

  • Consuming     Cloud Foundry services
Using Cloud Foundry
Example vmc commands
$ vmc target <any cloud>

$ vmc login <credentials>

$ vmc push <my-app>


   > bind services? Yes

$ vmc update <my-app>

$ vmc instances <my-app> +100
Sinatra + Redis
require 'sinatra'
require 'redis'           Connect to Redis

configure do
	 $r = Redis.new(:host => '127.0.0.1', :port => '6379') if !$r
end

get '/' do
 "Hello World! " + $r.incr("hitcounter").to_s
end
                                                Increment hit
                                                   counter

http://sgce2012.cloudfoundry.com/
One step deployment
---
applications:
  ./storefront:                   Path to application
    name: nodestore
    framework:
     name: node
     info:
      mem: 64M
      description: Node.js Application
      exec:
    url: ${name}.${target-base}
    mem: 64M
    instances: 1
    services:
     si-redis:
                             Required platform services
      type: redis
     si-rabbit:
      type: rabbitmq
One step deployment
applications:
 standalone-inventory/target/appassembler:                     Path to application
  name: standalone-shipping
  framework:
   name: standalone
   info:
    description: Standalone Application
    exec:
  runtime: java
  command: bin/standalone-shipping
  url:
  mem: 512M
  instances: 1
  services:                       Required platform services
   si-rabbit:
    type: rabbitmq
   si-mongo:
    type: mongodb
One step deployment
$ vmc push

Would you like to deploy from the current directory? [Yn]:

Pushing application 'inventory'...

Creating Application: OK

Creating Service [si-rabbit]: OK

Binding Service [si-rabbit]: OK

Creating Service [si-mongo]: OK

Binding Service [si-mongo]: OK
                                              vmc push:
Creating Service [si-redis]: OK               •Reads the manifest file
Binding Service [si-redis]: OK                •Creates the required platform services
Uploading Application:
                                              •Deploys all the applications
 Checking for available resources: OK

 Processing resources: OK

 Packing application: OK

 Uploading (12K): OK

Push Status: OK

Staging Application 'inventory': OK

Starting Application 'inventory': OK

Pushing application 'store'...
Micro Cloud Foundry =
             your sandbox
         App Instances                           Services




Open source Platform as a Service project




                                                       10.04



A PaaS packaged as a VMware Virtual Machine
                             Use as a developer sandbox
                             • Use the services from Junit integration tests
                             • Deploy your application for functional testing
                             • Remote debugging from STS
Agenda

• The   (sometimes evil) monolith

• Refactoring   to a modular, polyglot architecture

• Deploying   modular, polyglot applications

  • Overview    of Cloud Foundry

  • Using   Cloud Foundry

  • Consuming     Cloud Foundry services
Cloud Foundry services
Creating a service instance
$ vmc create-service mysql mysql1
Creating Service: OK

$ vmc services
......

=========== Provisioned Services ============
+-------------+---------+
| Name        | Service |
+-------------+---------+
| mysql1      | mysql   |
+-------------+---------+

$
Binding a service to an
            application
   $ vmc push cer-spring --path web/target/
   Application Deployed URL [cer-spring.cloudfoundry.com]:
   Detected a Java SpringSource Spring Application, is this correct? [Yn]:
   Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:
   Creating Application: OK
Would you like to bind any services to 'cer-spring'? [yN]: y [yN]: y
    Would you like
                   to bind any services to 'cer-spring'?
Would you like to use anan existing provisioned service? [yN]: y
    Would you like
                   to use existing provisioned service? [yN]: y
The The following provisioned servicesavailable
     following provisioned services are are available
1: mysql1
    1: mysql1
2: mysql-135e0
    2: mysql-135e0
Please select one you wish to use:use: 1
    Please select one you wish to 1
Binding Service [mysql1]: OK OK
    Binding Service [mysql1]:
   Uploading Application:
     Checking for available resources: OK
     Processing resources: OK
     Packing application: OK
     Uploading (12K): OK
Bindings exposed through
VCAP_SERVICES environment variable
    {    "mysql-5.1": [{
             "name": "mysql1",
             "label": "mysql-5.1",
             "plan": "free",
             "tags": ["mysql", "mysql-5.1", "relational"],
             "credentials": {
                 "name": "da81b57c25cca4c65929a223f0ed068a0",
                 "host": "172.99.99.99",
                 "port": 3306,
                 "username": "secretusername",
                 "password": "secretuserpassword"
                 ....
             }
        }]
    }
Accessing bound services:
                   low-level
var services = JSON.parse(process.env.VCAP_SERVICES);
var creds = services['mysql-5.1'][0].credentials




configure do
    services = JSON.parse(ENV['VCAP_SERVICES'])
    mysql_key = services.keys.select { |svc| svc =~ /mysql/i }.first
    mysql = services[mysql_key].first['credentials']
    mysql_conf = {:host => mysql['hostname'], :port => mysql['port'],
        :username => mysql['user'], :password => mysql['password']}
    @@client = Mysql2::Client.new mysql_conf
end
Accessing bound services:
         high-level, Spring/Java
CloudEnvironment environment = new CloudEnvironment();
RdbmsServiceInfo mysqlSvc =
    environment.getServiceInfo("mysqlService", RdbmsServiceInfo.class);
RdbmsServiceCreator dataSourceCreator = new RdbmsServiceCreator();
DataSource dataSource = dataSourceCreator.createService(mysqlSvc);

         <cloud:data-source id="dataSource" service-name="mysql1">
           <cloud:pool pool-size="1-5"/>
           <cloud:connection properties="charset=utf-8"/>
         </cloud:data-source>
         ...

                                reconfigured automatically
              <bean id="dataSource" class="…">
                  … DataSource for MySQL instance …
              </bean>
Accessing bound services:
            high-level, Ruby
                     reconfigured automatically
RedisHost = "127.0.0.1"
RedisPort = 10000
$r = Redis.new(:host => RedisHost, :port => RedisPort) if !$r



                      rewritten automatically
        production:
          adapter: sqlite3
          database: db/production.sqlite3
          pool: 5
          timeout: 5000
The human body as a system
50 to 70 billion of your cells die
            each day
Yet you (the system) remain you
Can we build software systems
  with these characteristics?
                 http://dreamsongs.com/Files/
             DesignBeyondHumanAbilitiesSimp.pdf


               http://dreamsongs.com/Files/
                   WhitherSoftware.pdf
@crichardson crichardson@vmware.com
http://plainoldobjects.com/presentations/




         Questions?
www.cloudfoundry.com @cloudfoundry

Developing polyglot applications on Cloud Foundry (#oredev 2012)

  • 1.
    Developing polyglot applications on Cloud Foundry Chris Richardson Author of POJOs in Action Founder of the original CloudFoundry.com @crichardson crichardson@vmware.com http://plainoldobjects.com/
  • 2.
    Presentation goal Modular, polyglot applications: what, why and how? How Cloud Foundry simplifies their development and deployment
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
    vmc push About-Chris Developer Advocate for CloudFoundry.com Signup at http://cloudfoundry.com
  • 9.
    Agenda • The (sometimes evil) monolith • Refactoring to a modular, polyglot architecture • Deploying modular, polyglot applications
  • 10.
    Let’s imagine youare building an e-commerce application
  • 11.
    Traditional web application architecture WAR StoreFrontUI Accounting Service MySQL Browser Apache Database InventoryService Simple to Shipping Service develop test Tomcat deploy scale
  • 12.
    But there areproblems
  • 13.
    Users expect arich, dynamic and interactive experience h oug d en HTTP Request oo ’t g Browser e isn Java Web Application HTML/Javascript ec tur it ar ch e UI s tyl Old Real-time web ≅ NodeJS
  • 14.
    Limitations of relational databases • Scalability • Distribution • Schema updates • O/R impedance mismatch • Handling semi-structured data
  • 15.
  • 16.
  • 17.
    Obstacle to frequent deployments • Need to redeploy everything to change one component • Increases risk of failure, e.g. interrupts background jobs Fear of change • Extensive test cycle • Updates will happen less often, e.g. Makes A/B testing UI really difficult
  • 18.
    Overloads your IDEand container Slows down development
  • 19.
    Obstacle to scalingdevelopment But the I want to update backend is not the UI working yet! Lots of coordination and communication required
  • 20.
    Requires long-term commitmentto a technology stack
  • 21.
    Agenda • The (sometimes evil) monolith • Refactoring to a modular, polyglot architecture • Decomposing applications into services • Using NoSQL • Presentation layer design • Deploying modular, polyglot applications
  • 23.
    The scale cube Yaxis - functional decomposition ila g sim nin Scale by r ing ing tio splitting th litt r ti sp pa different things by data s ale - Sc is ax Z X axis - horizontal duplication
  • 24.
    Y-axis scaling -application level WAR StoreFrontUI Accounting Service InventoryService Shipping Service
  • 25.
    Y-axis scaling -application level accounting application Accounting Service Store front web application inventory application StoreFrontUI InventoryService shipping application Shipping Service Apply X axis cloning and/or Z axis partitioning to each service
  • 26.
    Drawbacks of Y-axissplits • Complexity • Partitioned databases and transaction management • Deciding when to use this approach
  • 27.
    But there aremany benefits • Scales development: develop, deploy and scale each service independently • Less for each developer to learn • Doesn’t overload IDE or container • Improves fault isolation • Eliminates long-term commitment to a single technology stack
  • 28.
    Two levels ofarchitecture System-level Services Inter-service glue: interfaces and communication mechanisms Slow changing Service-level Internal architecture of each service Each service can use a different technology stack Pick the best tool for the job Rapidly evolving - regularly rewrite
  • 29.
    Modular, polyglot, applications
  • 30.
    Inter-service communication options • Transports: Synchronous HTTP asynchronous AMQP • Formats: JSON, XML, Protocol Buffers, Thrift, ... Asynchronous is preferred but REST is fine JSON is fashionable but binary format is more efficient
  • 31.
    Asynchronous message-based communication accounting application Accounting Service storefront web application inventory application RabbitMQ StoreFrontUI (Message InventoryService MySQL Broker) shipping application ShippingService
  • 32.
    Agenda • The (sometimes evil) monolith • Refactoring to a modular, polyglot architecture • Decomposing applications into services • Using NoSQL • Presentation layer design • Deploying modular, polyglot applications
  • 33.
    Solution: Use NoSQL Benefits Drawbacks • Higher performance • Limited transactions • Higher scalability • Limited querying • Richer data-model • Relaxed consistency • Schema-less • Unconstrained data
  • 34.
    Example NoSQL Databases Database Key features Cassandra Extensible column store, very scalable, distributed Neo4j Graph database Document-oriented, fast, scalable MongoDB Redis Key-value store, very fast http://nosql-database.org/ lists 122+ NoSQL databases
  • 35.
    NoSQL and thescale cube nin a ing itio dr rd r t an ha pa ss s Ca DB g go on M MongoDB replica sets Cassandra replication
  • 36.
    The future ispolyglot IEEE Software Sept/October 2010 - Debasish Ghosh / Twitter @debasishg
  • 37.
    Polyglot persistence architecture accounting application Accounting Service MySQL storefront web application inventory application RabbitMQ StoreFrontUI (Message InventoryService Redis Broker) shipping application ShippingService Mongo
  • 38.
    Agenda • The (sometimes evil) monolith • Refactoring to a modular, polyglot architecture • Decomposing applications into services • Using NoSQL • Presentation layer design • Deploying modular, polyglot applications
  • 39.
    Modular application Choice ofpresentation layer technology
  • 40.
    NodeJS is thefashionable technology
  • 41.
    Why NodeJS? • Familiar JavaScript • High-performance, scalable event-driven, non-blocking I/O model • Over 13,000 17,000 modules developed by the community • ManyJavaScript client frameworks have a NodeJS counterpart, e.g. socket.io and SockJS
  • 42.
    Why not NodeJS? a.k.a. callback hell
  • 43.
    A modern webapplication REST Node JS Service 1 Browser Service 2 Events HTML 5 Server Application Application Socket.io Socket.io client server ...
  • 44.
    NodeJS as amediator REST REST Service Node JS Events AMQP AMQP socket.io RabbitMQ Service
  • 45.
    Socket.io - server-side varexpress = require('express') , http = require('http') , amqp = require(‘amqp’) ....; server.listen(8081); Handle socket.io ... connection var amqpCon = amqp.createConnection(...); io.sockets.on('connection', function (socket) { Republish as function amqpMessageHandler(message, headers, deliveryInfo) { socket.io event var m = JSON.parse(message.data.toString()); socket.emit(‘tick’, m); }; amqpCon.queue(“myQueue”, {}, function(queue) { Subscribe to AMQP queue.bind(“myExchange”, “myBindingKey”); queue.subscribe(amqpMessageHandler); queue }); });
  • 46.
    Socket.io - client-side <html> <body> Theevent is <span data-bind="text: ticker"></span> <script src="/socket.io/socket.io.js"></script> <script src="/knockout-2.0.0.js"></script> <script src="/clock.js"></script> </body> Bind to model Connect to </html> socket.io server clock.js var socket = io.connect(location.hostname); function ClockModel() { self.ticker = ko.observable(1); Subscribe to tick socket.on('tick', function (data) { event self.ticker(data); }); }; Update model ko.applyBindings(new ClockModel());
  • 47.
    Modular, polyglot architecture p, Native Mobile application HTML5 mobile application lo Desktop Browser StoreUI StoreUI StoreUI ve de Asynchronous, NodeJS ? NodeJS Javascript scalable is StoreUI communication th te e w RabbitMQ st oy do Spring/Scala Standalone web application Inventory Inventory Shipping Service “headless” pl Service Shipping Service Spring/Java ow applications de Billing Service Redis Inventory Mongo Order H Database Database d an MySQL Customer Database
  • 48.
    Agenda • The (sometimes evil) monolith • Refactoring to a modular, polyglot architecture • Deploying modular, polyglot applications • Overview of Cloud Foundry • Using Cloud Foundry • Consuming Cloud Foundry services
  • 49.
    The Open Platform as a Service Deploy and scale polyglot applications in seconds, without locking yourself into a single cloud ible, pen , Flex Sim ple, O lable Sca
  • 50.
    OSS community vFabric Postgres Ap Private   Clouds   p Data Services lica 'o n  S vFabric Public erv RabbitMQTM ice Msg Services Clouds  In ter fac Micro e Other Services Clouds Additional partners services …
  • 51.
    CloudFoundry.COM - Multi- tenantPaaS operated by VMware CloudFoundry.COM (beta) Services Runtimes & Frameworks vCenter / vSphere Infrastructure
  • 52.
    Micro Cloud – FoundryTM Industry first downloadable PaaS App Instances Services Open source Platform as a Service project A cloud packaged as a VMware Virtual Machine
  • 53.
    CloudFoundry.ORG - VibrantApache 2 licensed open-source project CloudFoundry.ORG Your Infrastructure Download Setup Deploy Behind Code Environment BOSH Firewall
  • 54.
    Cloud Foundry: youcan trade-off Less effort vs flexibility Less Public PaaS .... .COM Private PaaS Effort .... Flexibility Custom Private PaaS git clone git://github.com/cloudfoundry/vcap.git More More
  • 55.
    Agenda • The (sometimes evil) monolith • Refactoring to a modular, polyglot architecture • Deploying modular, polyglot applications • Overview of Cloud Foundry • Using Cloud Foundry • Consuming Cloud Foundry services
  • 56.
  • 57.
    Example vmc commands $vmc target <any cloud> $ vmc login <credentials> $ vmc push <my-app> > bind services? Yes $ vmc update <my-app> $ vmc instances <my-app> +100
  • 58.
    Sinatra + Redis require'sinatra' require 'redis' Connect to Redis configure do $r = Redis.new(:host => '127.0.0.1', :port => '6379') if !$r end get '/' do "Hello World! " + $r.incr("hitcounter").to_s end Increment hit counter http://sgce2012.cloudfoundry.com/
  • 60.
    One step deployment --- applications: ./storefront: Path to application name: nodestore framework: name: node info: mem: 64M description: Node.js Application exec: url: ${name}.${target-base} mem: 64M instances: 1 services: si-redis: Required platform services type: redis si-rabbit: type: rabbitmq
  • 61.
    One step deployment applications: standalone-inventory/target/appassembler: Path to application name: standalone-shipping framework: name: standalone info: description: Standalone Application exec: runtime: java command: bin/standalone-shipping url: mem: 512M instances: 1 services: Required platform services si-rabbit: type: rabbitmq si-mongo: type: mongodb
  • 62.
    One step deployment $vmc push Would you like to deploy from the current directory? [Yn]: Pushing application 'inventory'... Creating Application: OK Creating Service [si-rabbit]: OK Binding Service [si-rabbit]: OK Creating Service [si-mongo]: OK Binding Service [si-mongo]: OK vmc push: Creating Service [si-redis]: OK •Reads the manifest file Binding Service [si-redis]: OK •Creates the required platform services Uploading Application: •Deploys all the applications Checking for available resources: OK Processing resources: OK Packing application: OK Uploading (12K): OK Push Status: OK Staging Application 'inventory': OK Starting Application 'inventory': OK Pushing application 'store'...
  • 63.
    Micro Cloud Foundry= your sandbox App Instances Services Open source Platform as a Service project 10.04 A PaaS packaged as a VMware Virtual Machine Use as a developer sandbox • Use the services from Junit integration tests • Deploy your application for functional testing • Remote debugging from STS
  • 64.
    Agenda • The (sometimes evil) monolith • Refactoring to a modular, polyglot architecture • Deploying modular, polyglot applications • Overview of Cloud Foundry • Using Cloud Foundry • Consuming Cloud Foundry services
  • 65.
  • 66.
    Creating a serviceinstance $ vmc create-service mysql mysql1 Creating Service: OK $ vmc services ...... =========== Provisioned Services ============ +-------------+---------+ | Name | Service | +-------------+---------+ | mysql1 | mysql | +-------------+---------+ $
  • 67.
    Binding a serviceto an application $ vmc push cer-spring --path web/target/ Application Deployed URL [cer-spring.cloudfoundry.com]: Detected a Java SpringSource Spring Application, is this correct? [Yn]: Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]: Creating Application: OK Would you like to bind any services to 'cer-spring'? [yN]: y [yN]: y Would you like to bind any services to 'cer-spring'? Would you like to use anan existing provisioned service? [yN]: y Would you like to use existing provisioned service? [yN]: y The The following provisioned servicesavailable following provisioned services are are available 1: mysql1 1: mysql1 2: mysql-135e0 2: mysql-135e0 Please select one you wish to use:use: 1 Please select one you wish to 1 Binding Service [mysql1]: OK OK Binding Service [mysql1]: Uploading Application: Checking for available resources: OK Processing resources: OK Packing application: OK Uploading (12K): OK
  • 68.
    Bindings exposed through VCAP_SERVICESenvironment variable { "mysql-5.1": [{ "name": "mysql1", "label": "mysql-5.1", "plan": "free", "tags": ["mysql", "mysql-5.1", "relational"], "credentials": { "name": "da81b57c25cca4c65929a223f0ed068a0", "host": "172.99.99.99", "port": 3306, "username": "secretusername", "password": "secretuserpassword" .... } }] }
  • 69.
    Accessing bound services: low-level var services = JSON.parse(process.env.VCAP_SERVICES); var creds = services['mysql-5.1'][0].credentials configure do services = JSON.parse(ENV['VCAP_SERVICES']) mysql_key = services.keys.select { |svc| svc =~ /mysql/i }.first mysql = services[mysql_key].first['credentials'] mysql_conf = {:host => mysql['hostname'], :port => mysql['port'], :username => mysql['user'], :password => mysql['password']} @@client = Mysql2::Client.new mysql_conf end
  • 70.
    Accessing bound services: high-level, Spring/Java CloudEnvironment environment = new CloudEnvironment(); RdbmsServiceInfo mysqlSvc = environment.getServiceInfo("mysqlService", RdbmsServiceInfo.class); RdbmsServiceCreator dataSourceCreator = new RdbmsServiceCreator(); DataSource dataSource = dataSourceCreator.createService(mysqlSvc); <cloud:data-source id="dataSource" service-name="mysql1"> <cloud:pool pool-size="1-5"/> <cloud:connection properties="charset=utf-8"/> </cloud:data-source> ... reconfigured automatically <bean id="dataSource" class="…"> … DataSource for MySQL instance … </bean>
  • 71.
    Accessing bound services: high-level, Ruby reconfigured automatically RedisHost = "127.0.0.1" RedisPort = 10000 $r = Redis.new(:host => RedisHost, :port => RedisPort) if !$r rewritten automatically production: adapter: sqlite3 database: db/production.sqlite3 pool: 5 timeout: 5000
  • 72.
    The human bodyas a system
  • 73.
    50 to 70billion of your cells die each day
  • 74.
    Yet you (thesystem) remain you
  • 75.
    Can we buildsoftware systems with these characteristics? http://dreamsongs.com/Files/ DesignBeyondHumanAbilitiesSimp.pdf http://dreamsongs.com/Files/ WhitherSoftware.pdf
  • 76.