SlideShare a Scribd company logo
Decomposing applications for
deployability and scalability
  Chris Richardson


  Author of POJOs in Action
  Founder of the original CloudFoundry.com


   @crichardson
  chris.richardson@springsource.com
  http://plainoldobjects.com




                                             @crichardson
Presentation goal
How decomposing applications
  improves deployability and
         scalability
            and
   How Cloud Foundry helps
                             @crichardson
About Chris




              @crichardson
(About Chris)




                @crichardson
About Chris()




                @crichardson
About Chris




              @crichardson
About Chris




   http://www.theregister.co.uk/2009/08/19/springsource_cloud_foundry/




                                                                    @crichardson
vmc push About-Chris

         Developer Advocate




 Signup at http://cloudfoundry.com


                                 @crichardson
Agenda

The (sometimes evil) monolith
Decomposing applications into services
How do services communicate?
Presentation layer design
How Cloud Foundry helps



                                         @crichardson
Let’s imagine you are building
an e-commerce application



                           @crichardson
Traditional web application
architecture                 WAR



                       StoreFrontUI


                       Accounting
                        Service         MySQL
Browser       Apache
                                       Database
                        Inventory
                         Service

                        Shipping
                        Service


Simple to
    develop               Tomcat

      test
    deploy
     scale
                                      @crichardson
But there are problems with
 a monolithic architecture



                         @crichardson
Users expect a rich, dynamic
and interactive experience
                                                              h
                                                           oug
                                                     d   en
                                                  goo
                    HTTP Request
                                           is n’t
                                       e
                                ec tur            Java Web
                          hit
    Browser
                    HTML/Javascript               Application
                        I arc
              ty le U
          s
      Old



      Real-time web ≅ NodeJS

                                                                  @crichardson
Intimidates developers




                         @crichardson
Obstacle to frequent
deployments
 Need to redeploy everything to change one component
 Interrupts long running background (e.g. Quartz) jobs
 Increases risk of failure




                                  Fear of change




 Updates will happen less often
 e.g. Makes A/B testing UI really difficult
                                                         @crichardson
Overloads your IDE and
container




     Slows down development
                              @crichardson
Obstacle to scaling
development

      Accounting
                      E-commerce
      Engineering
                       application


      Shipping team




                                     @crichardson
Obstacle to scaling
development
                            WAR




        UI team        StoreFrontUI

       Accounting       Accounting

     Inventory team   InventoryService

      Shipping team       Shipping




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




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




                          @crichardson
Agenda

The (sometimes evil) monolith
Decomposing applications into services
How do services communicate?
Presentation layer design
How Cloud Foundry helps



                                         @crichardson
@crichardson
The scale cube

   Y axis -
  functional
decomposition

    Scale by




                                                                      sim ing
    splitting




                                                                              r
                                                                            n
                                                                          ila
                                                                litt rtitio
different things




                                                                     a
                                                             ng ing
                                                        by ta p

                                                                s
                                                              da
                                                             sp
                                                  Sc is -


                                                         thi
                                              ax
                                                    ale
                                              Z



                           X axis
                   - horizontal duplication                                       @crichardson
Y-axis scaling - application level

                       WAR




                    StoreFrontUI

                    Accounting
                     Service

                      Inventory
                       Service

                      Shipping
                      Service




                                     @crichardson
Y-axis scaling - application level
                                            accounting web application


                                                  Accounting
                                                   Service




     Store front web application              inventory web application



        StoreFrontUI                                 Inventory
                                                      Service




                                             shipping web application



                                                     Shipping
                                                     Service




  Apply X axis cloning and/or Z axis partitioning to each service
                                                                          @crichardson
Partitioning strategies...

 Partition by verb, e.g. shipping service
 Partition by noun, e.g. inventory service
 Single Responsibility Principle
 Unix utilities - do one focussed thing well




                                               @crichardson
...Partitioning strategies
 Too few
   Drawbacks of the monolithic architecture
 Too many - a.k.a. Nano-service anti-pattern
   Runtime overhead
   Potential risk of excessive network hops
   Potentially difficult to understand system

   Something of an art
                                               @crichardson
Example micro-service
require 'sinatra'

post '/' do
  phone_number = params[:From]
  registration_url = "#{ENV['REGISTRATION_URL']}?phoneNumber=#{URI.encode(phone_number, "+")}"
  <<-eof
	     <Response>
	     	      <Sms>To complete registration please go to #{registration_url}</Sms>
	     </Response>
eof
end




          For more on micro-services see
                   @fgeorge52
                                                                                      @crichardson
Service deployment options
                      Isolation, manageability

VM
Linux Container/LXC
JVM
JAR/WAR/OSGI bundle/...


                         Density/efficiency
                                                 @crichardson
Real world examples
             http://techblog.netflix.com/



             http://highscalability.com/amazon-architecture




             http://www.addsimplicity.com/downloads/
             eBaySDForum2006-11-29.pdf

             http://queue.acm.org/detail.cfm?id=1394128




                                                   @crichardson
There are drawbacks



                      @crichardson
Complexity

See Steve Yegge’s Google Platforms Rant re
              Amazon.com


                                        @crichardson
Multiple databases
            &
Transaction management


                   @crichardson
Implementing features that
  span multiple services



                        @crichardson
When to use it?
  In the beginning:
 •You don’t need it
 •It will slow you down




                           Later on:
                          •You need it
                          •Refactoring is painful
                                             @crichardson
But there are many benefits
Scales development: develop, deploy and scale each service
independently
Update UI independently
Improves fault isolation
Eliminates long-term commitment to a single technology stack




     Modular, polyglot, multi-
     framework applications
                                                        @crichardson
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 could use a different technology stack
                Pick the best tool for the job
                       Rapidly evolving

                                                           @crichardson
If services are small...

 Regularly rewrite using a better technology stack
 Adapt system to changing requirements and better
 technology without a total rewrite
 Pick the best developers rather than best <pick a
 language> developers polyglot culture




                                                     @crichardson
The human body as a system




                             @crichardson
50 to 70 billion of your cells die
           each day




                                @crichardson
Yet you (the system) remain you




                                  @crichardson
Can we build software systems
  with these characteristics?

                    http://dreamsongs.com/Files/
                DesignBeyondHumanAbilitiesSimp.pdf



             http://dreamsongs.com/Files/WhitherSoftware.pdf




                                                     @crichardson
Agenda

The (sometimes evil) monolith
Decomposing applications into services
How do services communicate?
Presentation layer design
How Cloud Foundry helps



                                         @crichardson
Inter-service communication
options
 Synchronous HTTP        asynchronous AMQP

 Formats: JSON, XML, Protocol Buffers, Thrift, ...
 Even via the database


      Asynchronous is preferred
JSON is fashionable but binary format
           is more efficient
                                                     @crichardson
Asynchronous message-based communication
                               wgrus-billing.war

                                Accounting
                                 Service




 wgrus-store.war              wgrus-inventory.war

                   RabbitMQ
 StoreFrontUI      (Message   InventoryService        MySQL
                    Broker)



                              wgrus-shipping.war


                              ShippingService




                                                    @crichardson
Benefits

Decouples caller from server
Caller unaware of server’s coordinates (URL)
Message broker buffers message when server is down/
slow
Supports a variety of communication patterns, e.g. point-
to-point, pub-sub, ...



                                                    @crichardson
Drawbacks


Additional complexity of message broker
Request/reply-style communication is more complex




                                               @crichardson
Writing code that calls
       services



                          @crichardson
The need for parallelism
                                  Service B
               b = serviceB()


                                              Call in parallel
                 c = serviceC()
Service A                         Service C



            d = serviceD(b, c)
                                  Service D


                                                      @crichardson
Java Futures are a great
concurrency abstraction

    http://en.wikipedia.org/wiki/
       Futures_and_promises
                                    @crichardson
Using Java Futures
public class Client {

    private ExecutorService executorService;
    private RemoteServiceProxy remoteServiceProxy;        Eventually contains result

    public void doSomething() throws ... {
        Future<Integer> result =
            executorService.submit(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                return remoteServiceProxy.invokeRemoteService();
            }
        });

         /// Do other things
                                                              When needed wait for result
        int r = result.get(500, TimeUnit.MILLISECONDS);

        System.out.println(r);

    }
}                                                                                 @crichardson
Better future implementations



 Guava ListenableFutures = better
 Scala’s composable Futures = really good
 Java 8 CompletableFuture = great




                                            @crichardson
Composable Futures
val f1 = Future {    ... ; 1 }
val f2 = Future {    ... ; 2 }
                                            Transforms Future

val f4 = f2.map(_ * 2)
assertEquals(4, Await.result(f4, 1 second))

                                      Combines two futures
val fzip = f1 zip f2
assertEquals((1, 2), Await.result(fzip, 1 second))




 http://doc.akka.io/docs/akka/2.0.1/scala/futures.html

                                                                @crichardson
Using Scala futures
def callB() : Future[...] = ...
def callC() : Future[...] = ...
def callD() : Future[...] = ...                           Two calls execute in parallel


val future = for {
  (b, c) <- callB() zip callC();
  d <- callD(b, c)
 } yield d                                                      And then invokes D



val result = Await.result(future, 1 second)


  http://doc.akka.io/docs/akka/2.0.1/scala/futures.html            Get the result of D

                                                                                @crichardson
Spring Integration
Provides the building blocks for a pipes
and filters architecture
Enables development of application
components that are
  loosely coupled
  insulated from messaging infrastructure
Messaging defined declaratively




                                            @crichardson
Handling partial failures
                                    Down?
                                    Slow?

    Service A           Service B



                Down?
                Slow?




                                    @crichardson
About Netflix
           > 1B API calls/day
  1 API call   average 6 service calls

      Fault tolerance is essential



               http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html


                                                                          @crichardson
How to run out of threads


HTTP Request      X
                  X
                   X
                Thread 1

               Thread 2
               Thread 3
                  X
               Thread n
               Execute thread
                                     Service A


                                                         X
                                                         Service B




                   pool         Eventually all threads     If service B is
                                                         down then thread
                Tomcat             will be blocked        will be blocked




                                                               @crichardson
Their approach
  Network timeouts and retries
  Invoke remote services via a bounded thread pool
  Use the Circuit Breaker pattern
  On failure:
    return default/cached data
    return error to caller
  https://github.com/Netflix/Hystrix

See my talk tomorrow for more details
                                @crichardson
Agenda

The (sometimes evil) monolith
Decomposing applications into services
How do services communicate?
Presentation layer design
How Cloud Foundry helps



                                         @crichardson
Presentation layer evolution....

                         WAR

                           StoreFrontUI



           HTML / HTTP         View         Controller
 Browser


                                          Model




                                                         @crichardson
...Presentation layer evolution
Browser                              Web application


                                                Static
  View      Controller                         content

                         JSON-REST
                                              RESTful
          Model                              Endpoints

      HTML 5 -            Events               Event
      JavaScript                              publisher

No elaborate, server-side web framework
                 required           @crichardson
How to publish events to
       browser?



                       @crichardson
NodeJS is the fashionable
technology




                            @crichardson
Why NodeJS?
Familiar Javascript
High-performance, scalable event-driven, non-blocking I/O
model
Compact runtime
Over 17,000 modules developed by the community
Simple event publishing using socket.io or SockJS




                                                     @crichardson
Why not NodeJS?




             a.k.a. callback hell


                               @crichardson
A modern web application
  Browser
                             Node JS
             RESTful WS                  Service 1
HTML 5/
                            Server
 Java
                          application    Service 2
 Script        Events
                             Socket.io
 Socket.io
  client
                              server
                                         Service 3




                                               @crichardson
NodeJS - using RESTful WS
  and AMQP
                       REST
                               Service
 REST
Requests




           Node JS


 Events
           socket.io
                       AMQP              AMQP
                              RabbitMQ          Service




                                                 @crichardson
Socket.io server-side
 var express = require('express')
   , http = require('http')
   , amqp = require(‘amqp’)
   ....;
                                                          Handle
 server.listen(8081);                                    socket.io
 ...
 var amqpCon = amqp.createConnection(...);
                                                        connection

 io.sockets.on('connection', function (socket) {

   function amqpMessageHandler(message, headers, deliveryInfo) {
       var m = JSON.parse(message.data.toString());
                                                                  Republish
       socket.emit(‘tick’, m);                                   as socket.io
    };
    amqpCon.queue(“”, {},
                                                                    event
        function(queue) {
          queue.bind(“myExchange”, “”);
          queue.subscribe(amqpMessageHandler);
    });                                                      Subscribe to
 });                                                         AMQP queue
 https://github.com/cer/nodejs-clock                              @crichardson
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>
                           Bind to model              Connect to
</body>
</html>
                                                       socket.io
           clock.js
var socket = io.connect(location.hostname);

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

The (sometimes evil) monolith
Decomposing applications into services
How do services communicate?
Presentation layer design
How Cloud Foundry helps



                                         @crichardson
Original architecture
                         WAR




                    StoreFrontUI

                     Accounting
                      Service
                                        MySQL
Browser   Apache
                                       Database
                   InventoryService


                      Shipping




                      Tomcat



                                      @crichardson
Modern architecture




                                                        p,
                                                     lo
                                            Native Mobile                HTML5 mobile
            Desktop Browser                                               application
                                             application




                                                  ve
                  StoreUI                        StoreUI                     StoreUI




                                          st de
                                               NodeJS




                                                ?
Asynchronous,                                                                          Javascript




                                              is
   scalable
communication                                    StoreUI


                                        te e

                                           th
                                           w
                                              RabbitMQ




                                        oy
                            do

 Spring/Scala                         pl                                                             Standalone
web application                 Inventory                          Shipping
                                                                                                      “headless”
            ow



                                 Service                           Service
                                   de
                                                                                                     Spring/Java
                                                                                                     applications
           H


                                      d


                                       MySQL
                                an



              Billing Service         Customer             Redis Inventory             Mongo Order
                                      Database               Database                   Database
                                                                                                     @crichardson
Traditional tools: monolithic
applications




                            @crichardson
Developing modular apps is
more difficult
Many more moving parts to manage
  Platform services: SQL, NoSQL, RabbitMQ
  Application services: your code
Who is going to setup the environments:
  the developer sandbox?
  ...

But Cloud Foundry helps...
                                            @crichardson
Easy polyglot application deployment and
service provisioning

                                                        OSS community
       Ap
          p   lica
                 'o


    vFabric
   Postgres                                                Private	
  
                      n	
  S



                                                           Clouds	
  
              Data Services
                              erv



         vFabric                                        Public
                                 i
                                ce



                                Msg
       RabbitMQTM
                                                        Clouds
                               Services
                                  	
  In




                                                     Micro
                                        ter




                                           Other
                                          Services
                                                     Clouds
                                           fac




                    Additional partners
                                              e




                       services …




                                                                         @crichardson
Creating a platform service
 instance
$ vmc create-service mysql mysql1
Creating Service: OK

$ vmc services
......

=========== Provisioned Services ============

+-------------+---------+
| Name        | Service |
+-------------+---------+
| mysql1      | mysql   |
+-------------+---------+


                                                @crichardson
Multi-application manifest -
part 1
 ---
 applications:
  inventory/target:                    Path to application
       name: inventory
       url: cer-inventory.chrisr.cloudfoundry.me
       framework:
        name: spring
        info:
         mem: 512M
         description: Java SpringSource Spring Application
         exec:
       mem: 512M
       instances: 1
       services:                             Required platform services
        si-rabbit:
         type: :rabbitmq
        si-mongo:
         type: :mongodb
        si-redis:
         type: :redis
                                                                          @crichardson
Multi-application manifest -
part 2
store/target:
                                                    Path to application
 name: store
 url: cer-store.chrisr.cloudfoundry.me
 framework:
  name: spring
  info:
   mem: 512M
   description: Java SpringSource Spring Application
   exec:
 mem: 512M
 instances: 1                            Required platform services
 services:
  si-mongo:
   type: :mongodb
  si-rabbit:
   type: :rabbitmq


                                                                          @crichardson
One command to create platform
services and deploy application
 $ 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            vmc push:
 Binding Service [si-mongo]: OK
                                            •Reads the manifest file
                                            •Creates the required platform services
 Creating Service [si-redis]: OK
 Binding Service [si-redis]: OK
 Uploading Application:
  Checking for available resources: OK
                                            •Deploys all the applications
  Processing resources: OK
  Packing application: OK
  Uploading (12K): OK
 Push Status: OK
 Staging Application 'inventory': OK
 Starting Application 'inventory': OK
 Pushing application 'store'...

                                                                               @crichardson
Micro Cloud Foundry: new developer 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                        @crichardson
Using Caldecott to tunnel
into your services




                            @crichardson
Caldecott = TCP over HTTP

           native
          protocol                                             native
                                         HTTP
Service                      Caldecott          Caldecott     protocol
                                                                         Service
 client              Port      gem              application
                     NNN




             Your computer                               Cloud Foundry




                                                                           @crichardson
Using Caldecott…
$ vmc tunnel
1: mysql-135e0
2: mysql1
Which service to tunnel to?: 2
Password: ********
Stopping Application: OK
Redeploying tunnel application 'caldecott'.
Uploading Application:
  Checking for available resources: OK
  Packing application: OK
  Uploading (1K): OK
Push Status: OK
Binding Service [mysql1]: OK
Staging Application: OK
Starting Application: OK
Getting tunnel connection info: OK

Service connection info:
  username : uMe6Apgw00AhS
  password : pKcD76PcZR7GZ
  name     : d7cb8afb52f084f3d9bdc269e7d99ab50

Starting tunnel to mysql1 on port 10000.
1: none
2: mysql
Which client would you like to start?: 2




                                                 @crichardson
…Using Caldecott
Launching 'mysql --protocol=TCP --host=localhost --port=10000 --
    user=uMe6Apgw00AhS --password=pKcD76PcZR7GZ
    d7cb8afb52f084f3d9bdc269e7d99ab50'

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 10944342
Server version: 5.1.54-rel12.5 Percona Server with XtraDB (GPL), Release 12.5,
    Revision 188

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>




                                                                       @crichardson
Running JUnit test with
Caldecott
  Configure your test code to use port + connection info




                                                          @crichardson
Summary



          @crichardson
Monolithic applications are
simple to develop and deploy

    BUT have significant
       drawbacks
                           @crichardson
Apply the scale cube

               Modular, polyglot, and
               scalable applications
               Services developed,
               deployed and scaled
               independently



                                @crichardson
Cloud Foundry helps
                                                            .js
                      Ap
                         p




                                                                                    e
                          lica



                                                                                        Private	
  




                                                                                 fac
  Data Services
                              'o




                                                                              ter
                                                                                        Clouds	
  
                                 n	
  S




                                                                       r	
  In
                                   erv




                                                                    ide
                                                                              Public
                                      i




                                                                  ov
                                       ce




                  Msg Services
                                         	
  In




                                                            	
  Pr
                                                                              Clouds
                                               ter




                                                          ud
                                                         Cl o
                                                  fac




                                                                  Micro
                                                     e




                                  Other
                                 Services
                                                                  Clouds




                                                                                                      @crichardson
@crichardson chris.richardson@springsource.com
           http://plainoldobjects.com




                Questions?

 www.cloudfoundry.com                        @crichardson

More Related Content

What's hot (9)

PDF
Building microservices with Scala, functional domain models and Spring Boot
Chris Richardson
 
PDF
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Chris Richardson
 
PDF
Making of a Successful Cloud Business
ACMBangalore
 
PDF
Jeff barr Seattle_interactive_2011_q4
Seattle Interactive Conference
 
PDF
Microsoft's Cloud OS Launch, Revisited
C/D/H Technology Consultants
 
PPTX
Mastering Chaos - A Netflix Guide to Microservices
Josh Evans
 
PDF
Windows Azure Overview
Stefano Paluello
 
PPTX
SQL Data Service Overview
Eric Nelson
 
PDF
Тестирование производительности Ajax приложений с помощью JMeter
automated-testing.info
 
Building microservices with Scala, functional domain models and Spring Boot
Chris Richardson
 
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Chris Richardson
 
Making of a Successful Cloud Business
ACMBangalore
 
Jeff barr Seattle_interactive_2011_q4
Seattle Interactive Conference
 
Microsoft's Cloud OS Launch, Revisited
C/D/H Technology Consultants
 
Mastering Chaos - A Netflix Guide to Microservices
Josh Evans
 
Windows Azure Overview
Stefano Paluello
 
SQL Data Service Overview
Eric Nelson
 
Тестирование производительности Ajax приложений с помощью JMeter
automated-testing.info
 

Viewers also liked (20)

PDF
Developing modular, polyglot applications with Spring (SpringOne India 2012)
Chris Richardson
 
PDF
Developing applications with Cloud Services (Devnexus 2013)
Chris Richardson
 
PDF
Polygot persistence for Java Developers - August 2011 / @Oakjug
Chris Richardson
 
PDF
Decomposing applications for deployability and scalability (SpringOne China 2...
Chris Richardson
 
PDF
Developing polyglot persistence applications (devnexus 2013)
Chris Richardson
 
PDF
Developing applications with Cloud Services #javaone 2012
Chris Richardson
 
PDF
Developing polyglot applications on Cloud Foundry (#oredev 2012)
Chris Richardson
 
PDF
Developing polyglot persistence applications #javaone 2012
Chris Richardson
 
PDF
Decomposing applications for scalability and deployability - svcc sv_code_ca...
Chris Richardson
 
PDF
Developing polyglot persistence applications (SpringOne India 2012)
Chris Richardson
 
PDF
Using Spring with NoSQL databases (SpringOne China 2012)
Chris Richardson
 
PDF
Improving application design with a rich domain model (springone 2007)
Chris Richardson
 
PDF
Developing polyglot persistence applications (SpringOne China 2012)
Chris Richardson
 
PDF
NodeJS: the good parts? A skeptic’s view (jax jax2013)
Chris Richardson
 
PDF
Microservices pattern language (microxchg microxchg2016)
Chris Richardson
 
PDF
Adventures with Microservices
Anand Agrawal
 
PDF
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
Chris Richardson
 
PDF
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Chris Richardson
 
PDF
API Microservices with Node.js and Docker
Apigee | Google Cloud
 
PPTX
Microservices with Node.js and Apache Cassandra
Jorge Bay Gondra
 
Developing modular, polyglot applications with Spring (SpringOne India 2012)
Chris Richardson
 
Developing applications with Cloud Services (Devnexus 2013)
Chris Richardson
 
Polygot persistence for Java Developers - August 2011 / @Oakjug
Chris Richardson
 
Decomposing applications for deployability and scalability (SpringOne China 2...
Chris Richardson
 
Developing polyglot persistence applications (devnexus 2013)
Chris Richardson
 
Developing applications with Cloud Services #javaone 2012
Chris Richardson
 
Developing polyglot applications on Cloud Foundry (#oredev 2012)
Chris Richardson
 
Developing polyglot persistence applications #javaone 2012
Chris Richardson
 
Decomposing applications for scalability and deployability - svcc sv_code_ca...
Chris Richardson
 
Developing polyglot persistence applications (SpringOne India 2012)
Chris Richardson
 
Using Spring with NoSQL databases (SpringOne China 2012)
Chris Richardson
 
Improving application design with a rich domain model (springone 2007)
Chris Richardson
 
Developing polyglot persistence applications (SpringOne China 2012)
Chris Richardson
 
NodeJS: the good parts? A skeptic’s view (jax jax2013)
Chris Richardson
 
Microservices pattern language (microxchg microxchg2016)
Chris Richardson
 
Adventures with Microservices
Anand Agrawal
 
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
Chris Richardson
 
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Chris Richardson
 
API Microservices with Node.js and Docker
Apigee | Google Cloud
 
Microservices with Node.js and Apache Cassandra
Jorge Bay Gondra
 
Ad

Similar to Decomposing applications for scalability and deployability (devnexus 2013) (20)

PDF
Decomposing applications for deployability and scalability #springone2gx #s12gx
Chris Richardson
 
PDF
Spring into the Cloud - JDC2012 Cairo, Egypt
Chris Richardson
 
PDF
#JaxLondon keynote: Developing applications with a microservice architecture
Chris Richardson
 
PDF
Developing Applications with a Micro Service Architecture - Chris Richardson
JAXLondon2014
 
KEY
Cloud Foundry Bootcamp
Joshua Long
 
PPTX
Codestrong 2012 breakout session the role of cloud services in your next ge...
Axway Appcelerator
 
PDF
eBay Architecture
Tony Ng
 
PDF
Flex For Java Developers - SDForum Java SIG
Chris Richardson
 
PDF
Alfresco Day Madrid - Cliente - Buongiorno
Toni de la Fuente
 
PDF
Alfresco day madrid cliente - buongiorno
Alfresco Software
 
PDF
Alfresco day madrid cliente - buongiorno
Alfresco Software
 
PDF
Developing applications with a microservice architecture (svcc)
Chris Richardson
 
PDF
MongoUK 2012
Monica Wilkinson
 
PDF
The value of a platform approach for ECM
Nuxeo
 
PPTX
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Axway Appcelerator
 
PDF
Microservices: Decomposing Applications for Deployability and Scalability (ja...
Chris Richardson
 
PDF
Decomposing applications for deployability and scalability(SpringSource webinar)
Chris Richardson
 
PDF
Developing applications with a microservice architecture (SVforum, microservi...
Chris Richardson
 
PDF
The Future of Business Applications
OrangeScape
 
PDF
PaaS isn't Just for Developers
Gordon Haff
 
Decomposing applications for deployability and scalability #springone2gx #s12gx
Chris Richardson
 
Spring into the Cloud - JDC2012 Cairo, Egypt
Chris Richardson
 
#JaxLondon keynote: Developing applications with a microservice architecture
Chris Richardson
 
Developing Applications with a Micro Service Architecture - Chris Richardson
JAXLondon2014
 
Cloud Foundry Bootcamp
Joshua Long
 
Codestrong 2012 breakout session the role of cloud services in your next ge...
Axway Appcelerator
 
eBay Architecture
Tony Ng
 
Flex For Java Developers - SDForum Java SIG
Chris Richardson
 
Alfresco Day Madrid - Cliente - Buongiorno
Toni de la Fuente
 
Alfresco day madrid cliente - buongiorno
Alfresco Software
 
Alfresco day madrid cliente - buongiorno
Alfresco Software
 
Developing applications with a microservice architecture (svcc)
Chris Richardson
 
MongoUK 2012
Monica Wilkinson
 
The value of a platform approach for ECM
Nuxeo
 
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Axway Appcelerator
 
Microservices: Decomposing Applications for Deployability and Scalability (ja...
Chris Richardson
 
Decomposing applications for deployability and scalability(SpringSource webinar)
Chris Richardson
 
Developing applications with a microservice architecture (SVforum, microservi...
Chris Richardson
 
The Future of Business Applications
OrangeScape
 
PaaS isn't Just for Developers
Gordon Haff
 
Ad

More from Chris Richardson (20)

PDF
The microservice architecture: what, why, when and how?
Chris Richardson
 
PDF
More the merrier: a microservices anti-pattern
Chris Richardson
 
PDF
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
Chris Richardson
 
PDF
Dark Energy, Dark Matter and the Microservices Patterns?!
Chris Richardson
 
PDF
Dark energy, dark matter and microservice architecture collaboration patterns
Chris Richardson
 
PDF
Scenarios_and_Architecture_SkillsMatter_April_2022.pdf
Chris Richardson
 
PDF
Using patterns and pattern languages to make better architectural decisions
Chris Richardson
 
PDF
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
Chris Richardson
 
PDF
Events to the rescue: solving distributed data problems in a microservice arc...
Chris Richardson
 
PDF
A pattern language for microservices - June 2021
Chris Richardson
 
PDF
QConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
Chris Richardson
 
PDF
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...
Chris Richardson
 
PDF
Designing loosely coupled services
Chris Richardson
 
PDF
Microservices - an architecture that enables DevOps (T Systems DevOps day)
Chris Richardson
 
PDF
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
Chris Richardson
 
PDF
Decompose your monolith: Six principles for refactoring a monolith to microse...
Chris Richardson
 
PDF
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
Chris Richardson
 
PDF
Overview of the Eventuate Tram Customers and Orders application
Chris Richardson
 
PDF
An overview of the Eventuate Platform
Chris Richardson
 
PDF
#DevNexus202 Decompose your monolith
Chris Richardson
 
The microservice architecture: what, why, when and how?
Chris Richardson
 
More the merrier: a microservices anti-pattern
Chris Richardson
 
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...
Chris Richardson
 
Dark Energy, Dark Matter and the Microservices Patterns?!
Chris Richardson
 
Dark energy, dark matter and microservice architecture collaboration patterns
Chris Richardson
 
Scenarios_and_Architecture_SkillsMatter_April_2022.pdf
Chris Richardson
 
Using patterns and pattern languages to make better architectural decisions
Chris Richardson
 
iSAQB gathering 2021 keynote - Architectural patterns for rapid, reliable, fr...
Chris Richardson
 
Events to the rescue: solving distributed data problems in a microservice arc...
Chris Richardson
 
A pattern language for microservices - June 2021
Chris Richardson
 
QConPlus 2021: Minimizing Design Time Coupling in a Microservice Architecture
Chris Richardson
 
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...
Chris Richardson
 
Designing loosely coupled services
Chris Richardson
 
Microservices - an architecture that enables DevOps (T Systems DevOps day)
Chris Richardson
 
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...
Chris Richardson
 
Decompose your monolith: Six principles for refactoring a monolith to microse...
Chris Richardson
 
TDC2020 - The microservice architecture: enabling rapid, reliable, frequent a...
Chris Richardson
 
Overview of the Eventuate Tram Customers and Orders application
Chris Richardson
 
An overview of the Eventuate Platform
Chris Richardson
 
#DevNexus202 Decompose your monolith
Chris Richardson
 

Recently uploaded (20)

PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
July Patch Tuesday
Ivanti
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
July Patch Tuesday
Ivanti
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 

Decomposing applications for scalability and deployability (devnexus 2013)

  • 1. Decomposing applications for deployability and scalability Chris Richardson Author of POJOs in Action Founder of the original CloudFoundry.com @crichardson [email protected] http://plainoldobjects.com @crichardson
  • 2. Presentation goal How decomposing applications improves deployability and scalability and How Cloud Foundry helps @crichardson
  • 3. About Chris @crichardson
  • 4. (About Chris) @crichardson
  • 5. About Chris() @crichardson
  • 6. About Chris @crichardson
  • 7. About Chris http://www.theregister.co.uk/2009/08/19/springsource_cloud_foundry/ @crichardson
  • 8. vmc push About-Chris Developer Advocate Signup at http://cloudfoundry.com @crichardson
  • 9. Agenda The (sometimes evil) monolith Decomposing applications into services How do services communicate? Presentation layer design How Cloud Foundry helps @crichardson
  • 10. Let’s imagine you are building an e-commerce application @crichardson
  • 11. Traditional web application architecture WAR StoreFrontUI Accounting Service MySQL Browser Apache Database Inventory Service Shipping Service Simple to develop Tomcat test deploy scale @crichardson
  • 12. But there are problems with a monolithic architecture @crichardson
  • 13. Users expect a rich, dynamic and interactive experience h oug d en goo HTTP Request is n’t e ec tur Java Web hit Browser HTML/Javascript Application I arc ty le U s Old Real-time web ≅ NodeJS @crichardson
  • 14. Intimidates developers @crichardson
  • 15. Obstacle to frequent deployments Need to redeploy everything to change one component Interrupts long running background (e.g. Quartz) jobs Increases risk of failure Fear of change Updates will happen less often e.g. Makes A/B testing UI really difficult @crichardson
  • 16. Overloads your IDE and container Slows down development @crichardson
  • 17. Obstacle to scaling development Accounting E-commerce Engineering application Shipping team @crichardson
  • 18. Obstacle to scaling development WAR UI team StoreFrontUI Accounting Accounting Inventory team InventoryService Shipping team Shipping @crichardson
  • 19. Obstacle to scaling development But I want the backend is not working to update the UI yet! Lots of coordination and communication required @crichardson
  • 20. Requires long-term commitment to a technology stack @crichardson
  • 21. Agenda The (sometimes evil) monolith Decomposing applications into services How do services communicate? Presentation layer design How Cloud Foundry helps @crichardson
  • 23. The scale cube Y axis - functional decomposition Scale by sim ing splitting r n ila litt rtitio different things a ng ing by ta p s da sp Sc is - thi ax ale Z X axis - horizontal duplication @crichardson
  • 24. Y-axis scaling - application level WAR StoreFrontUI Accounting Service Inventory Service Shipping Service @crichardson
  • 25. Y-axis scaling - application level accounting web application Accounting Service Store front web application inventory web application StoreFrontUI Inventory Service shipping web application Shipping Service Apply X axis cloning and/or Z axis partitioning to each service @crichardson
  • 26. Partitioning strategies... Partition by verb, e.g. shipping service Partition by noun, e.g. inventory service Single Responsibility Principle Unix utilities - do one focussed thing well @crichardson
  • 27. ...Partitioning strategies Too few Drawbacks of the monolithic architecture Too many - a.k.a. Nano-service anti-pattern Runtime overhead Potential risk of excessive network hops Potentially difficult to understand system Something of an art @crichardson
  • 28. Example micro-service require 'sinatra' post '/' do phone_number = params[:From] registration_url = "#{ENV['REGISTRATION_URL']}?phoneNumber=#{URI.encode(phone_number, "+")}" <<-eof <Response> <Sms>To complete registration please go to #{registration_url}</Sms> </Response> eof end For more on micro-services see @fgeorge52 @crichardson
  • 29. Service deployment options Isolation, manageability VM Linux Container/LXC JVM JAR/WAR/OSGI bundle/... Density/efficiency @crichardson
  • 30. Real world examples http://techblog.netflix.com/ http://highscalability.com/amazon-architecture http://www.addsimplicity.com/downloads/ eBaySDForum2006-11-29.pdf http://queue.acm.org/detail.cfm?id=1394128 @crichardson
  • 31. There are drawbacks @crichardson
  • 32. Complexity See Steve Yegge’s Google Platforms Rant re Amazon.com @crichardson
  • 33. Multiple databases & Transaction management @crichardson
  • 34. Implementing features that span multiple services @crichardson
  • 35. When to use it? In the beginning: •You don’t need it •It will slow you down Later on: •You need it •Refactoring is painful @crichardson
  • 36. But there are many benefits Scales development: develop, deploy and scale each service independently Update UI independently Improves fault isolation Eliminates long-term commitment to a single technology stack Modular, polyglot, multi- framework applications @crichardson
  • 37. 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 could use a different technology stack Pick the best tool for the job Rapidly evolving @crichardson
  • 38. If services are small... Regularly rewrite using a better technology stack Adapt system to changing requirements and better technology without a total rewrite Pick the best developers rather than best <pick a language> developers polyglot culture @crichardson
  • 39. The human body as a system @crichardson
  • 40. 50 to 70 billion of your cells die each day @crichardson
  • 41. Yet you (the system) remain you @crichardson
  • 42. Can we build software systems with these characteristics? http://dreamsongs.com/Files/ DesignBeyondHumanAbilitiesSimp.pdf http://dreamsongs.com/Files/WhitherSoftware.pdf @crichardson
  • 43. Agenda The (sometimes evil) monolith Decomposing applications into services How do services communicate? Presentation layer design How Cloud Foundry helps @crichardson
  • 44. Inter-service communication options Synchronous HTTP asynchronous AMQP Formats: JSON, XML, Protocol Buffers, Thrift, ... Even via the database Asynchronous is preferred JSON is fashionable but binary format is more efficient @crichardson
  • 45. Asynchronous message-based communication wgrus-billing.war Accounting Service wgrus-store.war wgrus-inventory.war RabbitMQ StoreFrontUI (Message InventoryService MySQL Broker) wgrus-shipping.war ShippingService @crichardson
  • 46. Benefits Decouples caller from server Caller unaware of server’s coordinates (URL) Message broker buffers message when server is down/ slow Supports a variety of communication patterns, e.g. point- to-point, pub-sub, ... @crichardson
  • 47. Drawbacks Additional complexity of message broker Request/reply-style communication is more complex @crichardson
  • 48. Writing code that calls services @crichardson
  • 49. The need for parallelism Service B b = serviceB() Call in parallel c = serviceC() Service A Service C d = serviceD(b, c) Service D @crichardson
  • 50. Java Futures are a great concurrency abstraction http://en.wikipedia.org/wiki/ Futures_and_promises @crichardson
  • 51. Using Java Futures public class Client { private ExecutorService executorService; private RemoteServiceProxy remoteServiceProxy; Eventually contains result public void doSomething() throws ... { Future<Integer> result = executorService.submit(new Callable<Integer>() { @Override public Integer call() throws Exception { return remoteServiceProxy.invokeRemoteService(); } }); /// Do other things When needed wait for result int r = result.get(500, TimeUnit.MILLISECONDS); System.out.println(r); } } @crichardson
  • 52. Better future implementations Guava ListenableFutures = better Scala’s composable Futures = really good Java 8 CompletableFuture = great @crichardson
  • 53. Composable Futures val f1 = Future { ... ; 1 } val f2 = Future { ... ; 2 } Transforms Future val f4 = f2.map(_ * 2) assertEquals(4, Await.result(f4, 1 second)) Combines two futures val fzip = f1 zip f2 assertEquals((1, 2), Await.result(fzip, 1 second)) http://doc.akka.io/docs/akka/2.0.1/scala/futures.html @crichardson
  • 54. Using Scala futures def callB() : Future[...] = ... def callC() : Future[...] = ... def callD() : Future[...] = ... Two calls execute in parallel val future = for { (b, c) <- callB() zip callC(); d <- callD(b, c) } yield d And then invokes D val result = Await.result(future, 1 second) http://doc.akka.io/docs/akka/2.0.1/scala/futures.html Get the result of D @crichardson
  • 55. Spring Integration Provides the building blocks for a pipes and filters architecture Enables development of application components that are loosely coupled insulated from messaging infrastructure Messaging defined declaratively @crichardson
  • 56. Handling partial failures Down? Slow? Service A Service B Down? Slow? @crichardson
  • 57. About Netflix > 1B API calls/day 1 API call average 6 service calls Fault tolerance is essential http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html @crichardson
  • 58. How to run out of threads HTTP Request X X X Thread 1 Thread 2 Thread 3 X Thread n Execute thread Service A X Service B pool Eventually all threads If service B is down then thread Tomcat will be blocked will be blocked @crichardson
  • 59. Their approach Network timeouts and retries Invoke remote services via a bounded thread pool Use the Circuit Breaker pattern On failure: return default/cached data return error to caller https://github.com/Netflix/Hystrix See my talk tomorrow for more details @crichardson
  • 60. Agenda The (sometimes evil) monolith Decomposing applications into services How do services communicate? Presentation layer design How Cloud Foundry helps @crichardson
  • 61. Presentation layer evolution.... WAR StoreFrontUI HTML / HTTP View Controller Browser Model @crichardson
  • 62. ...Presentation layer evolution Browser Web application Static View Controller content JSON-REST RESTful Model Endpoints HTML 5 - Events Event JavaScript publisher No elaborate, server-side web framework required @crichardson
  • 63. How to publish events to browser? @crichardson
  • 64. NodeJS is the fashionable technology @crichardson
  • 65. Why NodeJS? Familiar Javascript High-performance, scalable event-driven, non-blocking I/O model Compact runtime Over 17,000 modules developed by the community Simple event publishing using socket.io or SockJS @crichardson
  • 66. Why not NodeJS? a.k.a. callback hell @crichardson
  • 67. A modern web application Browser Node JS RESTful WS Service 1 HTML 5/ Server Java application Service 2 Script Events Socket.io Socket.io client server Service 3 @crichardson
  • 68. NodeJS - using RESTful WS and AMQP REST Service REST Requests Node JS Events socket.io AMQP AMQP RabbitMQ Service @crichardson
  • 69. Socket.io server-side var express = require('express') , http = require('http') , amqp = require(‘amqp’) ....; Handle server.listen(8081); socket.io ... var amqpCon = amqp.createConnection(...); connection io.sockets.on('connection', function (socket) { function amqpMessageHandler(message, headers, deliveryInfo) { var m = JSON.parse(message.data.toString()); Republish socket.emit(‘tick’, m); as socket.io }; amqpCon.queue(“”, {}, event function(queue) { queue.bind(“myExchange”, “”); queue.subscribe(amqpMessageHandler); }); Subscribe to }); AMQP queue https://github.com/cer/nodejs-clock @crichardson
  • 70. 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> Bind to model Connect to </body> </html> socket.io clock.js var socket = io.connect(location.hostname); function ClockModel() { self.ticker = ko.observable(1); Subscribe socket.on('tick', function (data) { self.ticker(data); to tick event }); }; Update ko.applyBindings(new ClockModel()); model @crichardson
  • 71. Agenda The (sometimes evil) monolith Decomposing applications into services How do services communicate? Presentation layer design How Cloud Foundry helps @crichardson
  • 72. Original architecture WAR StoreFrontUI Accounting Service MySQL Browser Apache Database InventoryService Shipping Tomcat @crichardson
  • 73. Modern architecture p, lo Native Mobile HTML5 mobile Desktop Browser application application ve StoreUI StoreUI StoreUI st de NodeJS ? Asynchronous, Javascript is scalable communication StoreUI te e th w RabbitMQ oy do Spring/Scala pl Standalone web application Inventory Shipping “headless” ow Service Service de Spring/Java applications H d MySQL an Billing Service Customer Redis Inventory Mongo Order Database Database Database @crichardson
  • 75. Developing modular apps is more difficult Many more moving parts to manage Platform services: SQL, NoSQL, RabbitMQ Application services: your code Who is going to setup the environments: the developer sandbox? ... But Cloud Foundry helps... @crichardson
  • 76. Easy polyglot application deployment and service provisioning OSS community Ap p lica 'o vFabric Postgres Private   n  S Clouds   Data Services erv vFabric Public i ce Msg RabbitMQTM Clouds Services  In Micro ter Other Services Clouds fac Additional partners e services … @crichardson
  • 77. Creating a platform service instance $ vmc create-service mysql mysql1 Creating Service: OK $ vmc services ...... =========== Provisioned Services ============ +-------------+---------+ | Name | Service | +-------------+---------+ | mysql1 | mysql | +-------------+---------+ @crichardson
  • 78. Multi-application manifest - part 1 --- applications: inventory/target: Path to application name: inventory url: cer-inventory.chrisr.cloudfoundry.me framework: name: spring info: mem: 512M description: Java SpringSource Spring Application exec: mem: 512M instances: 1 services: Required platform services si-rabbit: type: :rabbitmq si-mongo: type: :mongodb si-redis: type: :redis @crichardson
  • 79. Multi-application manifest - part 2 store/target: Path to application name: store url: cer-store.chrisr.cloudfoundry.me framework: name: spring info: mem: 512M description: Java SpringSource Spring Application exec: mem: 512M instances: 1 Required platform services services: si-mongo: type: :mongodb si-rabbit: type: :rabbitmq @crichardson
  • 80. One command to create platform services and deploy application $ 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 vmc push: Binding Service [si-mongo]: OK •Reads the manifest file •Creates the required platform services Creating Service [si-redis]: OK Binding Service [si-redis]: OK Uploading Application: Checking for available resources: OK •Deploys all the applications Processing resources: OK Packing application: OK Uploading (12K): OK Push Status: OK Staging Application 'inventory': OK Starting Application 'inventory': OK Pushing application 'store'... @crichardson
  • 81. Micro Cloud Foundry: new developer 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 @crichardson
  • 82. Using Caldecott to tunnel into your services @crichardson
  • 83. Caldecott = TCP over HTTP native protocol native HTTP Service Caldecott Caldecott protocol Service client Port gem application NNN Your computer Cloud Foundry @crichardson
  • 84. Using Caldecott… $ vmc tunnel 1: mysql-135e0 2: mysql1 Which service to tunnel to?: 2 Password: ******** Stopping Application: OK Redeploying tunnel application 'caldecott'. Uploading Application: Checking for available resources: OK Packing application: OK Uploading (1K): OK Push Status: OK Binding Service [mysql1]: OK Staging Application: OK Starting Application: OK Getting tunnel connection info: OK Service connection info: username : uMe6Apgw00AhS password : pKcD76PcZR7GZ name : d7cb8afb52f084f3d9bdc269e7d99ab50 Starting tunnel to mysql1 on port 10000. 1: none 2: mysql Which client would you like to start?: 2 @crichardson
  • 85. …Using Caldecott Launching 'mysql --protocol=TCP --host=localhost --port=10000 -- user=uMe6Apgw00AhS --password=pKcD76PcZR7GZ d7cb8afb52f084f3d9bdc269e7d99ab50' Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 10944342 Server version: 5.1.54-rel12.5 Percona Server with XtraDB (GPL), Release 12.5, Revision 188 Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> @crichardson
  • 86. Running JUnit test with Caldecott Configure your test code to use port + connection info @crichardson
  • 87. Summary @crichardson
  • 88. Monolithic applications are simple to develop and deploy BUT have significant drawbacks @crichardson
  • 89. Apply the scale cube Modular, polyglot, and scalable applications Services developed, deployed and scaled independently @crichardson
  • 90. Cloud Foundry helps .js Ap p e lica Private   fac Data Services 'o ter Clouds   n  S r  In erv ide Public i ov ce Msg Services  In  Pr Clouds ter ud Cl o fac Micro e Other Services Clouds @crichardson
  • 91. @crichardson [email protected] http://plainoldobjects.com Questions? www.cloudfoundry.com @crichardson