SlideShare a Scribd company logo
1 of 111
Download to read offline
Spring into the Cloud
Chris Richardson

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

@crichardson
crichardson@vmware.com




                                           1
Presentation goal


     Cloud Foundry simplifies
       the development and
      deployment of modern
            applications

      Spring is the ideal cloud
        computing platform
                                  2
About Chris




              3
About Chris




              4
(About Chris)




                5
About Chris()




                6
About Chris




              7
About Chris




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




                                                                            8
About Chris




          Developer Advocate for
            CloudFoundry.com



 Signup at http://cloudfoundry.com

          Promo code: EgyptJUG
                                     9
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
 Cloud Foundry and asynchronous architectures
Traditional web application architecture

                                        WAR


                                                StoreFront


                                                Accounting
                                                 Service
                                                                      MySQL
   Desktop                                                            Database
                 Apache
   Browser                                    InventoryService


                                                  Shipping
                                                  Service


Simple to                      Tomcat

    develop
    test
    deploy
    scale                                                        Or is it?       11
Let’s imagine you want to run a
performance test...




         ?
How long to get the servers?
Who is going to set up the servers?
Who is going to set up Apache,
Tomcat, and MySQL?
And things are changing:

This simple, monolithic architecture is
             inadequate


                                      13
New kinds of clients




          Smart phones overtake PCs in Q4 2010

                                                 14
Users expect a rich, dynamic and interactive experience on mobile
                       devices and desktop




                                                                      h
                                                                   oug
                                                             d   en
                                                           oo
                                                       ’t g
                             HTTP Request
                                                  e isn
                                              r
                                          ctu
         Desktop                                          Java Web
                                        e
                                    hit
         Browser              HTML/Javascript            Application
                                  c
                             I ar
                   ty le U
              s
          Old




                                                                          15
Need to handle massive loads and the data explosion



               Need scalable architectures



 Application tier:
  • Replicated/clustered servers
  • Modular so that components can be scaled differently
  • Asynchronous architecture - communication via a message broker
 Database tier:
  • Replication
  • Sharding
  • Polyglot persistence: Relational, NoSQL, NewSQL databases
                                                                     16
Scaling development

       WAR


               StoreFront


               Accounting
                Service                 Scalable
                                     !=
             InventoryService           development
                 Shipping
                 Service




 Forces multiple developers/teams to synchronize development efforts
 Obstacle to frequent, independent deployments
 Increases risk of failure - need to redeploy everything to change one thing
                                                                                17
Modern application architecture

                                           billing.war

Desktop                                            Accounting
Browser                                             Service
 StoreUI


Native Mobile     NodeJS
                NodeJS                    inventory.war
Application     front-end
                                                                   MySQL
                application
                    StoreUI
 StoreUI                                        InventoryService


HTML5 mobile
application

 StoreUI          Redis                  shipping.war
                              RabbitMQ
                                                                   Mongo
                                               ShippingService




                                                                           18
Developing and testing these applications
       is even more challenging




                                            19
Let’s imagine you are fixing a bug
and want to run some JUnit
integration tests...




                ?
Who is going to install and configure
your sandbox: MySQL, RabbitMQ,
MongoDB, ....?
Let’s imagine you have fixed a bug
and want to run some functional
tests...




               ?
How long to purchase the servers?
Who is going to set up the servers?
Who is going to install and configure
MySQL, RabbitMQ, MongoDB, ....?
Platform-as-a-Service is the solution




  Easy deployment                           Services:
                                            Database
  Application management                +   Blob storage
                                            Messaging

  Easy scaling up and down                  ...




                                                           22
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
 Cloud Foundry and asynchronous architectures
About Cloud Foundry




                                                                       .js
                     Ap
                        p
                        lica




                                                                                                    Private	
  
                            7o




                                                                                                    Clouds	
  
                            n	
  S




  Data Services
                              erv




                                                                                                                         …
                                 i
                                 ce
                                   	
  In
                                         ter




                                                                              e
                                                                           fac
                                            fac




                                                                        ter
                                                                                           Public
                                               e




                                                                 r	
  In                   Clouds
                                                              ide
             Msg Services
                                                            ov
                                                      	
  Pr
                                                    ud
                                                   Cl o




                                                                                  Micro                           .COM
                                                                                  Clouds
                            Other Services




                                                                                                                             24
Cloud Foundry.COM
                          Cloud Foundry

  Runtimes & Frameworks

  Services

                          vCenter / vSphere




  Infrastructure
What is a Micro Cloud?




                                          Or




                  Entire Cloud Running inside of a single VM

Signup @ http://cloudfoundry.com/micro
                                                               26
Cloud Foundry.ORG


                           Cloud Foundry


                    The Cloud Foundry Source Code




      Download          Setup         Setup Scripts   Deploy Behind
                     Environment                        Firewall
        Code




                                                                      27
Vibrant open-source ecosystem
 AppFog.com
  • Community lead for PHP
  • PaaS for PHP
 Joyent
  • Community lead for Node.js
 ActiveState
  • Community lead for Python
  • Stackato private PaaS
Cloud Foundry - Architecture


                        Web
                      Web
                    Web
100’s of DEAs




                                                              Load Balancers
                                                             Load Balancers
                        App                                 Load Balancers
                      App
                    App
                                      Message Bus
                                      Message Bus
                                      Message Bus
                                        (NATS)
                                       (NATS)
                                        (NATS)
                         DEAs
                      DEAs
                    DEAs



                                                                 Routers
                                                                Routers
                                                               Routers


                         DB
                       DB
                      DB                         Cloud
                                              Cloud
                                              Controllers
                                            Cloud
                                            Controllers
                                          Controllers


                        Services                                Health
                                                               Health
                      Services                                Health
                                                                Manager
                    Services                                   Manager
                                                              Manager

                                       Web Service API
Let's deploy an application
Create an application


  $ mvn archetype:generate
  …
  18: internal -> maven-archetype-webapp
    (A simple Java web application)
  …
  Choose a number:
    (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/1
    6/17/18/19/20/21/22/23/24/25/26/27/28/
    29/30/31/32/33/34/35/36/37/38/39/40/41
    ) 15: : 18
  …
  $ mvn package
  …
Options for using Cloud Foundry




                                  32
Using the Cloud Foundry CLI



    CLI     Application name        Dir containing WAR




  vmc push cf1 --path target 
        --url cer-cf1.cloudfoundry.com




                               Application URL
Deploy the application


  $ vmc push cf1 --path target 
        --url cer-cf1.cloudfoundry.com
  Detected a Java Web Application, is this correct?
     [Yn]:

  Memory Reservation [Default:512M] (64M, 128M, 256M,
     512M, 1G or 2G)
  Creating Application: OK
  Would you like to bind any services to 'cf1'? [yN]:

  Uploading Application:
    Checking for available resources: OK
    Packing application: OK
    Uploading (2K): OK
  Push Status: OK
  Starting Application: OK
Access the application



  $ curl cer-cf1.cloudfoundry.com
  <html>
  <body>
  <h2>Hello World!</h2>
  </body>
  </html>
Change the application




  $ vi src/main/webapp/index.jsp
  $ mvn package
Update the running application



  $ vmc update cf1 --path target
  Uploading Application:
    Checking for available resources:
    OK
    Packing application: OK
    Uploading (2K): OK
  Push Status: OK
  Successfully updated Application:
    'cf1'
  Stopping Application: OK
  Starting Application: OK
Access it again




   $ curl cer-cf1.cloudfoundry.com
   <html>
   <body>
   <h2>This is Cloud Foundry</h2>
   </body>
   </html>
Scale the application




   $ vmc instances cf1 +2
   Scaling Application instances up to 3: OK


   $ vmc stats cf1

   +----------+-------------+----------------+--------------+--------------+
   | Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime       |
   +----------+-------------+----------------+--------------+--------------+
   | 0        | 1.2% (4)    | 90.6M (512M)   | 8.5M (2G)    | 0d:0h:3m:3s |
   | 1        | 9.5% (4)    | 60.9M (512M)   | 8.4M (2G)    | 0d:0h:0m:17s |
   | 2        | 9.4% (4)    | 55.5M (512M)   | 8.4M (2G)    | 0d:0h:0m:17s |
   +----------+-------------+----------------+--------------+--------------+
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
 Cloud Foundry and asynchronous architectures
Available services




                     41
Creating a service instance


  $ vmc create-service mysql --name mysql1
  Creating Service: OK

  $ vmc services
  ============== System Services ==============
  +------------+---------+---------------------------------------+
  | Service    | Version | Description                           |
  +------------+---------+---------------------------------------+
  | mongodb    | 1.8     | MongoDB NoSQL store                   |
  | mysql      | 5.1     | MySQL database service                |
  | postgresql | 9.0     | PostgreSQL database service (vFabric) |
  | rabbitmq   | 2.4     | RabbitMQ messaging service            |
  | redis      | 2.2     | Redis key-value store service         |
  +------------+---------+---------------------------------------+

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

  +-------------+---------+
  | Name        | Service |
  +-------------+---------+
  | mysql1      | mysql   |
  +-------------+---------+
Typical Spring application is cloud ready

<beans>

  <bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource"
    >
    <property name="driverClassName"
! !          !     value="com.mysql.jdbc.Driver" />
    <property name="url"
!      value="jdbc:mysql://localhost:3306/cf" />
    <property name="username" value="cfuser" />
    <property name="password" value="cfpassword" />
    …
  </bean>
                  class SomeClass {
                       @Autowired
                        private DataSource dataSource;
                  }
Deploying it


   $ 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
   Would you like to bind any services to 'cer-spring'?         [yN]: y
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
DataSource bean is reconfigured automatically

<beans>

 <bean id="dataSource" class="…">
     … DataSource for MySQL instance …
 </bean>

</beans>

               class SomeClass {
                    @Autowired
                     private DataSource dataSource;
               }
Using database tools
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
…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>
Testing scenario
 Create MySQL service instance
 Use Caldecott to tunnel database
 Populate DB using mysql+sql scripts
 Deploy application bound to database
 Test the application
 …
 Delete application and database
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
 Cloud Foundry and asynchronous architectures
Spring programming model
                                              Benefits:
                                             •Improved developer
                                             productivity
                                             •Higher quality code
                                             •Portability across
                      Dependency Injection   application servers




                           POJO

Portable Service                               Aspect-Oriented
Abstractions                                   Programming
(Transactions, data
access, …)

                                                                    51
Spring is ideal for the cloud environment

 Yet another environment for your application to run in
  • Different Java runtime
  • Different databases – sometimes not relational!
 Dynamic environment:
  • Servers come and go
  • IP addresses change
 Must integrate with in-house applications:
  • RPC
  • Asynchronous messaging
 To leverage elasticity your application must be architected to scale up and down
  • Asynchronous, loose coupling


    = Problems already solved by the Spring framework
Spring 3.1 features for cloud applications




                                             53
Spring configuration options




                           Auto-reconfiguration
 Cloud Foundry Runtime




                          <cloud:*/> namespace


                          CloudEnvironment API


                           VCAP_APPLICATION,
                         VCAP_SERVICES env vars
VCAP_APPLICATION


 {
     "instance_id": "e53853fe21d5d740aadf7ddcc0670b4e",
     "instance_index": 0,
     "name": "cer-spring",
     "uris": ["cer-spring.cloudfoundry.com"],
     "users": ["crichardson@vmware.com"],
     "version": "56892923b974db90a8f6c7120b665fb17cff7edb-1",
     "start": "2011-12-02 23:06:01 +0000",
     "runtime": "java",
     "state_timestamp": 1322867161,
     "port": 40198,
     "limits": {
         "fds": 256,
         "mem": 536870912,
         "disk": 2147483648
     },
     "host": "172.30.50.9"
VCAP_SERVICES


 {
     "mysql-5.1": [{
         "name": "mysql1",
         "label": "mysql-5.1",
         "plan": "free",
         "tags": ["mysql", "mysql-5.1", "relational"],
         "credentials": {
             "name": "d7cb8afb52f084f3d9bdc269e7d99ab50",
             "hostname": "172.30.48.20",
             "host": "172.30.48.20",
             "port": 3306,
             "user": "usmMRfwzyYG53",
             "username": "usmMRfwzyYG53",
             "password": "pxWSBVeu80GDp"
         }
     }]
CloudEnvironment:
          parses JSON so you don't have to


CloudEnvironment env = new CloudEnvironment();
Properties props = env.getCloudProperties();
String prop = props.getProperty(
   "cloud.services.mysql1.connection.hostname"
  );

ApplicationInstanceInfo instanceInfo =
   env.getInstanceInfo();
int port = instanceInfo.getPort();
List<String> urls = instanceInfo.getUris();
…
Provides access to ServiceInfo…




RdbmsServiceInfo mis =
  env.getServiceInfo(
! !     "mysql1",
! !     RdbmsServiceInfo.class);
String mySqlUrl = mis.getUrl();
… which can create DataSources etc

@Configuration
public class CloudDataSourceConfiguration {

    @Bean
    public DataSource dataSource() {
      CloudEnvironment environment = new CloudEnvironment();

        RdbmsServiceInfo mysqlSvc =
!          !       environment.getServiceInfo("mysql1",
                                               RdbmsServiceInfo.class);

!          RdbmsServiceCreator dataSourceCreator = new RdbmsServiceCreator();

        DataSource dataSource = dataSourceCreator.createService(mysqlSvc);

        return dataSource;
    }

}


                                                                             59
<cloud:*/> namespace



  Spring XML namespace
  Defines beans from CloudEnvironment
   • Connection factories, e.g. DataSource
   • Properties
<cloud:data-source/> Configures a JDBC DataSource



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




               @Autowired
               private DataSource dataSource ;




                                                             61
<cloud:properties>


   Exposes basic information about services that can be
    consumed with Spring’s property placeholder support
   Properties automatically available when deploying Spring
    3.1 applications


<cloud:properties id="cloudProperties" />
<context:property-placeholder
   properties-ref="cloudProperties"/>



class SomeClass {

@Value("${cloud.services.mysql1.connection.hostname}")
private String mysqlHost;


                                                               62
Configuring Cloud Foundry apps is easy

                BUT

    How to run on the desktop too?
Isolating Cloud Foundry configuration
 Use Spring 3.1 profiles
 Beans belong to one or more profiles
 At runtime, one or active profiles           active beans
 By default, default profile is active
 Activate profiles using
  • system property: -Dspring.active.profiles=profile1,profile2
  • programmatically
Using <beans profile=""/>

<bean class="org.sf.orm.jpa.LocalContainerEntityManagerFactoryBean">
     <property name="dataSource" ref="dataSource"/>
</bean>
                                   Outside of Cloud Foundry
<beans profile="default">
	      <bean class="org.a.commons.dbcp.BasicDataSource" id="dataSource">
	           <property name="url" value="jdbc:mysql://localhost/my_db" />
	      </bean>
</beans>
                                  Inside Cloud Foundry
<beans profile="cloud">
	      <cloud:data-source id="dataSource" />
</beans>
	

       Profiles available in Spring 3.1
                                                                       65
Using @Profile


@Configuration
@Profile("default")
public class LocalDataSourceConfiguration {
  @Configuration
   @Bean
  @Profile("cloud")
   public DataSource dataSource() {
  public class CloudDataSourceConfiguration {
   }
    @Bean
    public DataSource dataSource() {
}
  !    !    …
    }

  }
                                                66
Application configuration via environment variables


 $ vmc env-add cf1
     PAYMENT_SVC=http://...
 Adding Environment Variable
   [PAYMENT_SVC=http://...]: OK
 Stopping Application: OK
 Staging Application: OK

   String value = System.getenv("PAYMENT_SVC")

       @Value("#{systemEnvironment['PAYMENT_SVC']}")
       private String envVariable;
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
  • Why NoSQL?
  • Using MongoDB
  • Cloud Foundry and MongoDB
 Cloud Foundry and asynchronous architectures
Cloud Foundry provides NoSQL-aaS




   But what’s a NoSQL database?
   Why would you want to use it?
   How do you use it?
                                   69
Solution: Use NoSQL




 Benefits
• Higher performance
• Higher scalability
• Richer data-model
• Schema-less

                        Drawbacks
                       • Limited transactions
                       • Relaxed consistency
                       • Unconstrained data




                                                70
Future = multi-paradigm data storage for enterprise applications




                                                                             e.g. Netflix
                                                                            • RDBMS
                                                                            • SimpleDB
                                                                            • Cassandra
                                                                            • Hadoop/Hbase




    IEEE Software Sept/October 2010 - Debasish Ghosh / Twitter @debasishg




                                                                                             71
Spring Data is here to help




                                            For


                                  NoSQL databases

  http://www.springsource.org/spring-data




                                                    72
What you get

 Template classes that hide the boilerplate code, similar to JdbcTemplate
 Auto-generated (generic) repositories
 Java    NoSQL mapping
 Cross Store Persistence
 Support in Roo and Grails




                                                                             73
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
  • Why NoSQL?
  • Using MongoDB
  • Cloud Foundry and MongoDB
 Cloud Foundry and asynchronous architectures
MongoDB

 Document-oriented database
  • JSON-style documents: Lists, Maps, primitives
  • Schema-less
 Transaction = update of a single document
 Rich query language for dynamic queries
 Very fast
 Writes are asynchronous!
 Highly scalable and available




                                                    75
Data model = Binary JSON documents

 Server

   Database: Food To Go
     Collection: Restaurants
          {
              "name" : "Sahn Maru",
              "type" : ”Korean",
              "serviceArea" : [
                 "94619",
                 "94618"
              ],
              "openingHours" : [
                 {
                    "dayOfWeek" : "Wednesday",
                                                             Sequence of
                    "open" : 1730,                           bytes on disk
                    "close" : 2230
                 }                                            fast i/o
              ],
              "_id" : ObjectId("4bddc2f49d1505567c6220a0")
          }




                                                                        76
MongoDB use cases

 Use cases
  • High volume writes
  • Complex data
  • Semi-structured data
 Who is using it?
  • Shutterfly, Foursquare
  • Bit.ly Intuit
  • SourceForge, NY Times
  • GILT Groupe, Evite,
  • SugarCRM




                             77
MongoTemplate




Simplifies data access                   MongoTemplate                POJO  DBObject
Translates exceptions   databaseName                                      mapping
                        userId
                        Password
                        defaultCollectionName

                        writeConcern
                        writeResultChecking

                        save()                                               <<interface>>
                        insert()                                            MongoConvertor
                        remove()
                        updateFirst()                            write(Object, DBObject)
                        findOne()
                                                                 read(Class, DBObject)
                        find()
                        …




                                                          uses

                                          Mongo                              MongoMapping
                                    (Java Driver class)                       Converter


                                                                                             78
Example entity

public class Restaurant {
 private String id;
 private String name;
 private List<MenuItem> menuItems;

public Restaurant() {
}
                                           public class MenuItem {
public Restaurant(String name) {           private String name;
  this.name = name;                        private double price;
  …
}                                          public MenuItem() {
                                           }
public String getName() { return name; }
                                            public MenuItem(String name,
public void setName(String name) {                         double price) {
  this.name = name;                           this.name = name;
}                                             this.price = price;
                                            }
…getters and setters…
                                           …getters and setters…
                                                                             79
Example data access code


@Repository
public class RestaurantRepository {

 @Autowired
 private MongoTemplate mongoTemplate;

 public static final String RESTAURANTS_COLLECTION = "restaurants";


 public void add(Restaurant restaurant) {
   mongoTemplate.save(RESTAURANTS_COLLECTION, restaurant);
 }

  public List<Restaurant> findRestaurantsByName(String restaurantName) {
    return mongoTemplate.find(RESTAURANTS_COLLECTION, 	
	          new Query(where("name").is(restaurantName)),
	          Restaurant.class);
  }




                                                                          80
Mongo document



{
    "_id" : ObjectId("4d977f55d3fe3119c904e026"),
    "menuItems" : [
	           {
	           	       "name" : "Tandoori Portobello Mushrooms",
	           	       "price" : 5.5
	           },
	           {
	           	       "name" : "Duck Curry Kerala",
	           	       "price" : 15
	           }
       ],
     "name" : "Ajanta"
}



                                                                81
MongoDB bean definitions




                           82
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
  • Why NoSQL?
  • Using MongoDB
  • Cloud Foundry and MongoDB
 Cloud Foundry and asynchronous architectures
Using Mongo and Redis with Cloud Foundry

 Create a service - Mongo or Redis
 Bind it to your application
 Use <cloud:*/> namespace to access the bound service
  • when cloud profile is active




                                                         84
Deploying a Mongo application




                                85
Using the Mongo Application




                              86
NoSQL and Caldecott

 Caldecott let’s you tunnel to a NoSQL service
 Use Redis CLI
  • redis-cli
  • Explore database, adhoc operations
  • ...
 Use Mongo CLI etc
  • Explore database, adhoc operations
  • Mongo dump/restore
  • ...




                                                  87
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
 Cloud Foundry and asynchronous architectures
  • Why use messages?
  • RabbitMQ and Spring AMQP
  • Using Spring Integration
  • Using RabbitMQ on Cloud Foundry
Cloud Foundry provides
                                RabbitMQ - aaS




But what’s RabbitMQ?
Why would you want to use it?
How do you use it?



                                                         89
But why messaging? Why RabbitMQ?




         Application A                 Application B




                          RabbitMQ




               Traditional application integration



                                                       90
Messaging within applications        wgrus-billing.war

                                            Accounting
                                             Service




                                   wgrus-inventory.war

 wgrus-store.war                              Widget
                        Message          InventoryService
      StoreFront        Broker
                                                            MySQL
                                   wgrus-inventory.war

                                              Gadget
                                         InventoryService

   Decouples front-end from
   back-end
   Front-end continues to work    wgrus-shipping.war
   when back-end is down                  Shipping
   Broker smoothes out traffic            Service
   spikes                                                           91
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
 Cloud Foundry and asynchronous architectures
  • Why use messages?
  • RabbitMQ and Spring AMQP
  • Using Spring Integration
  • Using RabbitMQ on Cloud Foundry
RabbitMQ – Messaging that Just Works




                          Robust
                     High-performance
                        Easy to use
                      AMQP LEADER
Why AMQP?


 A	
  Protocol,	
  not	
  an	
  API
 •A defined set of
 messaging capabilities
 called the AMQ model
 •A network wire-level
 protocol, AMQP

                                      On	
  commodity	
  hardware
                                      •10-­‐25	
  thousand	
  messages	
  per	
  
                                      second	
  is	
  rou7ne	
  *
                                      •The	
  NIC	
  is	
  usually	
  the	
  
                                      boIleneck

                                         *	
  Non-­‐persistent	
  messages
17
Spring AMQP

 Encapsulates low-level details
                                         Producer          Consumer
 Simplifies sending and receiving of
  messages


                                          Amqp              Listener
                                         Template          Container



                                        Spring AMQP




                                                    AMQP
Sending AMQP messages


@Component public class MessageSender {

@Autowired
private volatile AmqpTemplate amqpTemplate;

public void send(String message) {
  this.amqpTemplate.convertAndSend(
       "myExchange", "some.routing.key", message);
}

public void read() throws Exception {
    ...
   String value =
    amqpTemplate.receiveAndConvert("myQueueName");
   ...
 }                                                   96
Spring AMQP is flexible and dynamic

                BUT

         It’s very low level




                                      97
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
 Cloud Foundry and asynchronous architectures
  • Why use messages?
  • RabbitMQ and Spring AMQP
  • Using Spring Integration
  • Using RabbitMQ on Cloud Foundry
Spring Integration

 Builds on Spring framework
 High-level of abstraction for building message
  based applications
 Implements EAI patterns
 Provides plumbing for exchanging messages
  between application components
 Promotes loosely coupled components
 Integrates with external messaging infrastructure:
  JMS, AMQP, HTTP, Email, File transfer




                                                       99
Spring Integration concepts

 Message channel
 • Virtual pipe connecting producer and consumer
 Message endpoints
 • The filter of a pipes-and-filter architecture
 • Read from and/or write to channel
 Endpoint types:
 • Transformer
 • Filter
 • Router
 • Splitter
 • Aggregator
 • ServiceActivator
 • Inbound channel adapter - read from external source, writes to channel
 • Outbound channel adapter - read from channel write to external destination

                                                                                100
Using Spring Integration with the web store
                application




                                          101
wgrus-store.war                                        wgrus-shipping.war


      StoreFront                                                Shipping
                                                                Service

     Spring Integration            RabbitMQ                   Spring Integration




wgrus-billing.war         wgrus-inventory.war


      Credit Service              Spring Integration



                                     Widget
                                InventoryService

                                     Gadget
                                InventoryService

                                                                                   102
Store front flow




StoreUI

                                             object to
           Message Endpoint   orderChannel               amqpOut   AMQP
                                              JSON




                                                                          103
Inventory flow


                                       Json to    credit check      inventory               inventory    Object to
 AMQP      inventory                                                                                                 AMQP
                                       Object       enricher        encricher              AMQP Out       JSON




                                                                                             inventory
                                                                                               router
                       credit check




                        credit check                                      Content Based
                           service                                           Router
                          activator




                                        Credit
                                        Service




                                                                   widget                  gadget
                                                                 inventory                inventory
                                                                  service                  service
                                                                                                                            104
Shipping flow




                                                 shipping
                                                  service
                           Json to
   AMQP         shipping             Service
                           Object
                 order               Activator
                channel




                                                            105
Agenda
 Why PaaS?
 Cloud Foundry basics
 Using Cloud Foundry services
 Spring and Cloud Foundry
 Using NoSQL databases
 Cloud Foundry and asynchronous architectures
  • Why use messages?
  • RabbitMQ and Spring AMQP
  • Using Spring Integration
  • Using RabbitMQ on Cloud Foundry
Rabbit on Cloud Foundry




                          107
Configuring a ConnectionFactory




<rabbit:template id="rabbitTemplate"
    connection-factory="rabbitConnectionFactory"/>

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

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




                                                                   108
Using Caldecott with RabbitMQ

 Use for JUnit/Integration tests
 Run RabbitMQ tools




               xxxxx
               xxxxx
               xxxxx




                                    109
Summary

 PaaS? Good.
 Cloud Foundry? Good.
 Spring? Good.
 Cloud Foundry and Spring? Really good!




 Home work:
 • Learn Spring: http://www.springframework.org
 • Learn Spring Data http://www.springframework.org/spring-data
 • sign up for (free) Cloud Foundry at http://www.cloudfoundry.com
 • Download the Cloud Foundry Micro Cloud



                                                                     110
@cloudfoundry @crichardson chris.richardson@springsource.com




                 Questions?
 www.cloudfoundry.com promo code EgyptJUG

More Related Content

What's hot

Microservices and elastic resource pools with Amazon EC2 Container Service
Microservices and elastic resource pools with Amazon EC2 Container ServiceMicroservices and elastic resource pools with Amazon EC2 Container Service
Microservices and elastic resource pools with Amazon EC2 Container ServiceBoyan Dimitrov
 
Multi-Source, Multi-Speed Data Consumption & Analytics on AWS
Multi-Source, Multi-Speed Data Consumption & Analytics on AWSMulti-Source, Multi-Speed Data Consumption & Analytics on AWS
Multi-Source, Multi-Speed Data Consumption & Analytics on AWSAmazon Web Services
 
How IT at Getty Images Brokers Cloud Services
How IT at Getty Images Brokers Cloud ServicesHow IT at Getty Images Brokers Cloud Services
How IT at Getty Images Brokers Cloud ServicesRightScale
 
Serverless Architectures on AWS - Pop-up Loft Tel Aviv
Serverless Architectures on AWS - Pop-up Loft Tel AvivServerless Architectures on AWS - Pop-up Loft Tel Aviv
Serverless Architectures on AWS - Pop-up Loft Tel AvivAmazon Web Services
 
Beyond PaaS v.s IaaS: How to Manage Both
Beyond PaaS v.s IaaS: How to Manage BothBeyond PaaS v.s IaaS: How to Manage Both
Beyond PaaS v.s IaaS: How to Manage BothRightScale
 
Kubernetes on AWS gone wild
Kubernetes on AWS gone wildKubernetes on AWS gone wild
Kubernetes on AWS gone wildChristian Jantz
 
Automating Cloud Operations: Tips from Managed Services
Automating Cloud Operations: Tips from Managed ServicesAutomating Cloud Operations: Tips from Managed Services
Automating Cloud Operations: Tips from Managed ServicesAngela_Tripp
 
Serverless Computing
Serverless Computing Serverless Computing
Serverless Computing Rushi Namani
 
Container Management with Amazon ECS
Container Management with Amazon ECSContainer Management with Amazon ECS
Container Management with Amazon ECSAWS Germany
 
AWS Customer Presentation - Netflix
AWS Customer Presentation - NetflixAWS Customer Presentation - Netflix
AWS Customer Presentation - NetflixAmazon Web Services
 
Nested Beanstalk Deployment - Brett Sutter, Minneapolis
 Nested Beanstalk Deployment - Brett Sutter, Minneapolis Nested Beanstalk Deployment - Brett Sutter, Minneapolis
Nested Beanstalk Deployment - Brett Sutter, MinneapolisAWS Chicago
 
Serverless Computing Model
Serverless Computing ModelServerless Computing Model
Serverless Computing ModelMohamed Samir
 
Techconnectseattle
TechconnectseattleTechconnectseattle
TechconnectseattleBlake Diers
 
Monitoring microservices platform
Monitoring microservices platformMonitoring microservices platform
Monitoring microservices platformBoyan Dimitrov
 

What's hot (20)

Microservices and elastic resource pools with Amazon EC2 Container Service
Microservices and elastic resource pools with Amazon EC2 Container ServiceMicroservices and elastic resource pools with Amazon EC2 Container Service
Microservices and elastic resource pools with Amazon EC2 Container Service
 
Multi-Source, Multi-Speed Data Consumption & Analytics on AWS
Multi-Source, Multi-Speed Data Consumption & Analytics on AWSMulti-Source, Multi-Speed Data Consumption & Analytics on AWS
Multi-Source, Multi-Speed Data Consumption & Analytics on AWS
 
Sundog Media Toolkit
Sundog Media Toolkit Sundog Media Toolkit
Sundog Media Toolkit
 
How IT at Getty Images Brokers Cloud Services
How IT at Getty Images Brokers Cloud ServicesHow IT at Getty Images Brokers Cloud Services
How IT at Getty Images Brokers Cloud Services
 
Serverless Architectures on AWS - Pop-up Loft Tel Aviv
Serverless Architectures on AWS - Pop-up Loft Tel AvivServerless Architectures on AWS - Pop-up Loft Tel Aviv
Serverless Architectures on AWS - Pop-up Loft Tel Aviv
 
Containerisation & Cloud Trends
Containerisation &  Cloud Trends Containerisation &  Cloud Trends
Containerisation & Cloud Trends
 
Beyond PaaS v.s IaaS: How to Manage Both
Beyond PaaS v.s IaaS: How to Manage BothBeyond PaaS v.s IaaS: How to Manage Both
Beyond PaaS v.s IaaS: How to Manage Both
 
Kubernetes on AWS gone wild
Kubernetes on AWS gone wildKubernetes on AWS gone wild
Kubernetes on AWS gone wild
 
Simplestream
SimplestreamSimplestream
Simplestream
 
Automating Cloud Operations: Tips from Managed Services
Automating Cloud Operations: Tips from Managed ServicesAutomating Cloud Operations: Tips from Managed Services
Automating Cloud Operations: Tips from Managed Services
 
Serverless Computing
Serverless Computing Serverless Computing
Serverless Computing
 
Container Management with Amazon ECS
Container Management with Amazon ECSContainer Management with Amazon ECS
Container Management with Amazon ECS
 
AWS Customer Presentation - Netflix
AWS Customer Presentation - NetflixAWS Customer Presentation - Netflix
AWS Customer Presentation - Netflix
 
Thinkbox Software
Thinkbox SoftwareThinkbox Software
Thinkbox Software
 
Nested Beanstalk Deployment - Brett Sutter, Minneapolis
 Nested Beanstalk Deployment - Brett Sutter, Minneapolis Nested Beanstalk Deployment - Brett Sutter, Minneapolis
Nested Beanstalk Deployment - Brett Sutter, Minneapolis
 
Serverless Computing Model
Serverless Computing ModelServerless Computing Model
Serverless Computing Model
 
Techconnectseattle
TechconnectseattleTechconnectseattle
Techconnectseattle
 
Ingest and storage options
Ingest and storage optionsIngest and storage options
Ingest and storage options
 
Monitoring microservices platform
Monitoring microservices platformMonitoring microservices platform
Monitoring microservices platform
 
ITV& Bashton
ITV& Bashton ITV& Bashton
ITV& Bashton
 

Viewers also liked

Polyglot persistence for Java developers - moving out of the relational comfo...
Polyglot persistence for Java developers - moving out of the relational comfo...Polyglot persistence for Java developers - moving out of the relational comfo...
Polyglot persistence for Java developers - moving out of the relational comfo...Chris Richardson
 
Decomposing applications for deployability and scalability (CF India July/Aug...
Decomposing applications for deployability and scalability (CF India July/Aug...Decomposing applications for deployability and scalability (CF India July/Aug...
Decomposing applications for deployability and scalability (CF India July/Aug...Chris Richardson
 
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012Patrick Chanezon
 
Decomposing applications for deployability and scalability (cfopentour india)
Decomposing applications for deployability and scalability (cfopentour india)Decomposing applications for deployability and scalability (cfopentour india)
Decomposing applications for deployability and scalability (cfopentour india)Chris Richardson
 
Map, flatmap and reduce are your new best friends (javaone, svcc)
Map, flatmap and reduce are your new best friends (javaone, svcc)Map, flatmap and reduce are your new best friends (javaone, svcc)
Map, flatmap and reduce are your new best friends (javaone, svcc)Chris Richardson
 
Docker OpenStack Cloud Foundry
Docker OpenStack Cloud FoundryDocker OpenStack Cloud Foundry
Docker OpenStack Cloud FoundryAnimesh Singh
 
Flex For Java Developers - SDForum Java SIG
Flex For Java Developers - SDForum Java SIGFlex For Java Developers - SDForum Java SIG
Flex For Java Developers - SDForum Java SIGChris Richardson
 
Developing polyglot persistence applications (oscon oscon2013)
Developing polyglot persistence applications (oscon oscon2013)Developing polyglot persistence applications (oscon oscon2013)
Developing polyglot persistence applications (oscon oscon2013)Chris Richardson
 

Viewers also liked (8)

Polyglot persistence for Java developers - moving out of the relational comfo...
Polyglot persistence for Java developers - moving out of the relational comfo...Polyglot persistence for Java developers - moving out of the relational comfo...
Polyglot persistence for Java developers - moving out of the relational comfo...
 
Decomposing applications for deployability and scalability (CF India July/Aug...
Decomposing applications for deployability and scalability (CF India July/Aug...Decomposing applications for deployability and scalability (CF India July/Aug...
Decomposing applications for deployability and scalability (CF India July/Aug...
 
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
 
Decomposing applications for deployability and scalability (cfopentour india)
Decomposing applications for deployability and scalability (cfopentour india)Decomposing applications for deployability and scalability (cfopentour india)
Decomposing applications for deployability and scalability (cfopentour india)
 
Map, flatmap and reduce are your new best friends (javaone, svcc)
Map, flatmap and reduce are your new best friends (javaone, svcc)Map, flatmap and reduce are your new best friends (javaone, svcc)
Map, flatmap and reduce are your new best friends (javaone, svcc)
 
Docker OpenStack Cloud Foundry
Docker OpenStack Cloud FoundryDocker OpenStack Cloud Foundry
Docker OpenStack Cloud Foundry
 
Flex For Java Developers - SDForum Java SIG
Flex For Java Developers - SDForum Java SIGFlex For Java Developers - SDForum Java SIG
Flex For Java Developers - SDForum Java SIG
 
Developing polyglot persistence applications (oscon oscon2013)
Developing polyglot persistence applications (oscon oscon2013)Developing polyglot persistence applications (oscon oscon2013)
Developing polyglot persistence applications (oscon oscon2013)
 

Similar to Spring into the Cloud with Cloud Foundry

Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry BootcampJoshua Long
 
Decomposing applications for deployability and scalability #springone2gx #s12gx
Decomposing applications for deployability and scalability #springone2gx #s12gxDecomposing applications for deployability and scalability #springone2gx #s12gx
Decomposing applications for deployability and scalability #springone2gx #s12gxChris Richardson
 
Decomposing applications for deployability and scalability (SpringOne China 2...
Decomposing applications for deployability and scalability (SpringOne China 2...Decomposing applications for deployability and scalability (SpringOne China 2...
Decomposing applications for deployability and scalability (SpringOne China 2...Chris Richardson
 
Leverage An Intelligent Application Infrastructure for Competitive Advantage.
Leverage An Intelligent Application Infrastructure for Competitive Advantage.Leverage An Intelligent Application Infrastructure for Competitive Advantage.
Leverage An Intelligent Application Infrastructure for Competitive Advantage.Eric D. Schabell
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREAraf Karsh Hamid
 
Elevating your Continuous Delivery Strategy Above the Rolling Clouds
Elevating your Continuous Delivery Strategy Above the Rolling CloudsElevating your Continuous Delivery Strategy Above the Rolling Clouds
Elevating your Continuous Delivery Strategy Above the Rolling CloudsMichael Elder
 
Cloud-Native Modernization or Death? A false dichotomy. | DevNation Tech Talk
Cloud-Native Modernization or Death? A false dichotomy. | DevNation Tech TalkCloud-Native Modernization or Death? A false dichotomy. | DevNation Tech Talk
Cloud-Native Modernization or Death? A false dichotomy. | DevNation Tech TalkRed Hat Developers
 
Say Goodbye to DIY Data Centers
Say Goodbye to DIY Data CentersSay Goodbye to DIY Data Centers
Say Goodbye to DIY Data CentersRackspace
 
Developing polyglot applications on Cloud Foundry (#oredev 2012)
Developing polyglot applications on Cloud Foundry (#oredev 2012)Developing polyglot applications on Cloud Foundry (#oredev 2012)
Developing polyglot applications on Cloud Foundry (#oredev 2012)Chris Richardson
 
GIDS_what does_cloud-native_mean_anyway?
GIDS_what does_cloud-native_mean_anyway?GIDS_what does_cloud-native_mean_anyway?
GIDS_what does_cloud-native_mean_anyway?Grace Jansen
 
CloudWorld: What Does Cloud-Native Mean Anyway?
CloudWorld: What Does Cloud-Native Mean Anyway?CloudWorld: What Does Cloud-Native Mean Anyway?
CloudWorld: What Does Cloud-Native Mean Anyway?Grace Jansen
 
Business Of Cloud Computing Workshop Final
Business Of Cloud Computing Workshop FinalBusiness Of Cloud Computing Workshop Final
Business Of Cloud Computing Workshop FinalMarc Crudgington, MBA
 
Architecture 2020 - eComputing 2019-07-01
Architecture 2020 - eComputing 2019-07-01Architecture 2020 - eComputing 2019-07-01
Architecture 2020 - eComputing 2019-07-01Jorge Hidalgo
 
Accelerate Digital Transformation with IBM Cloud Private
Accelerate Digital Transformation with IBM Cloud PrivateAccelerate Digital Transformation with IBM Cloud Private
Accelerate Digital Transformation with IBM Cloud PrivateMichael Elder
 

Similar to Spring into the Cloud with Cloud Foundry (20)

Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
 
Spring Into the Cloud
Spring Into the CloudSpring Into the Cloud
Spring Into the Cloud
 
Decomposing applications for deployability and scalability #springone2gx #s12gx
Decomposing applications for deployability and scalability #springone2gx #s12gxDecomposing applications for deployability and scalability #springone2gx #s12gx
Decomposing applications for deployability and scalability #springone2gx #s12gx
 
Decomposing applications for deployability and scalability (SpringOne China 2...
Decomposing applications for deployability and scalability (SpringOne China 2...Decomposing applications for deployability and scalability (SpringOne China 2...
Decomposing applications for deployability and scalability (SpringOne China 2...
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
MongoUK 2012
MongoUK 2012MongoUK 2012
MongoUK 2012
 
Leverage An Intelligent Application Infrastructure for Competitive Advantage.
Leverage An Intelligent Application Infrastructure for Competitive Advantage.Leverage An Intelligent Application Infrastructure for Competitive Advantage.
Leverage An Intelligent Application Infrastructure for Competitive Advantage.
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SRE
 
Cloud Foundry et le Cloud vu par VMware
Cloud Foundry et le Cloud vu par VMwareCloud Foundry et le Cloud vu par VMware
Cloud Foundry et le Cloud vu par VMware
 
Elevating your Continuous Delivery Strategy Above the Rolling Clouds
Elevating your Continuous Delivery Strategy Above the Rolling CloudsElevating your Continuous Delivery Strategy Above the Rolling Clouds
Elevating your Continuous Delivery Strategy Above the Rolling Clouds
 
Cloud-Native Modernization or Death? A false dichotomy. | DevNation Tech Talk
Cloud-Native Modernization or Death? A false dichotomy. | DevNation Tech TalkCloud-Native Modernization or Death? A false dichotomy. | DevNation Tech Talk
Cloud-Native Modernization or Death? A false dichotomy. | DevNation Tech Talk
 
Say Goodbye to DIY Data Centers
Say Goodbye to DIY Data CentersSay Goodbye to DIY Data Centers
Say Goodbye to DIY Data Centers
 
Developing polyglot applications on Cloud Foundry (#oredev 2012)
Developing polyglot applications on Cloud Foundry (#oredev 2012)Developing polyglot applications on Cloud Foundry (#oredev 2012)
Developing polyglot applications on Cloud Foundry (#oredev 2012)
 
GIDS_what does_cloud-native_mean_anyway?
GIDS_what does_cloud-native_mean_anyway?GIDS_what does_cloud-native_mean_anyway?
GIDS_what does_cloud-native_mean_anyway?
 
CloudWorld: What Does Cloud-Native Mean Anyway?
CloudWorld: What Does Cloud-Native Mean Anyway?CloudWorld: What Does Cloud-Native Mean Anyway?
CloudWorld: What Does Cloud-Native Mean Anyway?
 
Business Of Cloud Computing Workshop Final
Business Of Cloud Computing Workshop FinalBusiness Of Cloud Computing Workshop Final
Business Of Cloud Computing Workshop Final
 
Architecture 2020 - eComputing 2019-07-01
Architecture 2020 - eComputing 2019-07-01Architecture 2020 - eComputing 2019-07-01
Architecture 2020 - eComputing 2019-07-01
 
Accelerate Digital Transformation with IBM Cloud Private
Accelerate Digital Transformation with IBM Cloud PrivateAccelerate Digital Transformation with IBM Cloud Private
Accelerate Digital Transformation with IBM Cloud Private
 
agile microservices @scaibo
agile microservices @scaiboagile microservices @scaibo
agile microservices @scaibo
 

More from Chris Richardson

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

More from Chris Richardson (20)

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

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Spring into the Cloud with Cloud Foundry

  • 1. Spring into the Cloud Chris Richardson Author of POJOs in Action Founder of the original CloudFoundry.com @crichardson crichardson@vmware.com 1
  • 2. Presentation goal Cloud Foundry simplifies the development and deployment of modern applications Spring is the ideal cloud computing platform 2
  • 8. About Chris http://www.theregister.co.uk/2009/08/19/springsource_cloud_foundry/ 8
  • 9. About Chris Developer Advocate for CloudFoundry.com Signup at http://cloudfoundry.com Promo code: EgyptJUG 9
  • 10. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases  Cloud Foundry and asynchronous architectures
  • 11. Traditional web application architecture WAR StoreFront Accounting Service MySQL Desktop Database Apache Browser InventoryService Shipping Service Simple to Tomcat develop test deploy scale Or is it? 11
  • 12. Let’s imagine you want to run a performance test... ? How long to get the servers? Who is going to set up the servers? Who is going to set up Apache, Tomcat, and MySQL?
  • 13. And things are changing: This simple, monolithic architecture is inadequate 13
  • 14. New kinds of clients Smart phones overtake PCs in Q4 2010 14
  • 15. Users expect a rich, dynamic and interactive experience on mobile devices and desktop h oug d en oo ’t g HTTP Request e isn r ctu Desktop Java Web e hit Browser HTML/Javascript Application c I ar ty le U s Old 15
  • 16. Need to handle massive loads and the data explosion Need scalable architectures  Application tier: • Replicated/clustered servers • Modular so that components can be scaled differently • Asynchronous architecture - communication via a message broker  Database tier: • Replication • Sharding • Polyglot persistence: Relational, NoSQL, NewSQL databases 16
  • 17. Scaling development WAR StoreFront Accounting Service Scalable != InventoryService development Shipping Service  Forces multiple developers/teams to synchronize development efforts  Obstacle to frequent, independent deployments  Increases risk of failure - need to redeploy everything to change one thing 17
  • 18. Modern application architecture billing.war Desktop Accounting Browser Service StoreUI Native Mobile NodeJS NodeJS inventory.war Application front-end MySQL application StoreUI StoreUI InventoryService HTML5 mobile application StoreUI Redis shipping.war RabbitMQ Mongo ShippingService 18
  • 19. Developing and testing these applications is even more challenging 19
  • 20. Let’s imagine you are fixing a bug and want to run some JUnit integration tests... ? Who is going to install and configure your sandbox: MySQL, RabbitMQ, MongoDB, ....?
  • 21. Let’s imagine you have fixed a bug and want to run some functional tests... ? How long to purchase the servers? Who is going to set up the servers? Who is going to install and configure MySQL, RabbitMQ, MongoDB, ....?
  • 22. Platform-as-a-Service is the solution Easy deployment Services: Database Application management + Blob storage Messaging Easy scaling up and down ... 22
  • 23. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases  Cloud Foundry and asynchronous architectures
  • 24. About Cloud Foundry .js Ap p lica Private   7o Clouds   n  S Data Services erv … i ce  In ter e fac fac ter Public e r  In Clouds ide Msg Services ov  Pr ud Cl o Micro .COM Clouds Other Services 24
  • 25. Cloud Foundry.COM Cloud Foundry Runtimes & Frameworks Services vCenter / vSphere Infrastructure
  • 26. What is a Micro Cloud? Or Entire Cloud Running inside of a single VM Signup @ http://cloudfoundry.com/micro 26
  • 27. Cloud Foundry.ORG Cloud Foundry The Cloud Foundry Source Code Download Setup Setup Scripts Deploy Behind Environment Firewall Code 27
  • 28. Vibrant open-source ecosystem  AppFog.com • Community lead for PHP • PaaS for PHP  Joyent • Community lead for Node.js  ActiveState • Community lead for Python • Stackato private PaaS
  • 29. Cloud Foundry - Architecture Web Web Web 100’s of DEAs Load Balancers Load Balancers App Load Balancers App App Message Bus Message Bus Message Bus (NATS) (NATS) (NATS) DEAs DEAs DEAs Routers Routers Routers DB DB DB Cloud Cloud Controllers Cloud Controllers Controllers Services Health Health Services Health Manager Services Manager Manager Web Service API
  • 30. Let's deploy an application
  • 31. Create an application $ mvn archetype:generate … 18: internal -> maven-archetype-webapp (A simple Java web application) … Choose a number: (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/1 6/17/18/19/20/21/22/23/24/25/26/27/28/ 29/30/31/32/33/34/35/36/37/38/39/40/41 ) 15: : 18 … $ mvn package …
  • 32. Options for using Cloud Foundry 32
  • 33. Using the Cloud Foundry CLI CLI Application name Dir containing WAR vmc push cf1 --path target --url cer-cf1.cloudfoundry.com Application URL
  • 34. Deploy the application $ vmc push cf1 --path target --url cer-cf1.cloudfoundry.com Detected a Java Web Application, is this correct? [Yn]: Memory Reservation [Default:512M] (64M, 128M, 256M, 512M, 1G or 2G) Creating Application: OK Would you like to bind any services to 'cf1'? [yN]: Uploading Application: Checking for available resources: OK Packing application: OK Uploading (2K): OK Push Status: OK Starting Application: OK
  • 35. Access the application $ curl cer-cf1.cloudfoundry.com <html> <body> <h2>Hello World!</h2> </body> </html>
  • 36. Change the application $ vi src/main/webapp/index.jsp $ mvn package
  • 37. Update the running application $ vmc update cf1 --path target Uploading Application: Checking for available resources: OK Packing application: OK Uploading (2K): OK Push Status: OK Successfully updated Application: 'cf1' Stopping Application: OK Starting Application: OK
  • 38. Access it again $ curl cer-cf1.cloudfoundry.com <html> <body> <h2>This is Cloud Foundry</h2> </body> </html>
  • 39. Scale the application $ vmc instances cf1 +2 Scaling Application instances up to 3: OK $ vmc stats cf1 +----------+-------------+----------------+--------------+--------------+ | Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime | +----------+-------------+----------------+--------------+--------------+ | 0 | 1.2% (4) | 90.6M (512M) | 8.5M (2G) | 0d:0h:3m:3s | | 1 | 9.5% (4) | 60.9M (512M) | 8.4M (2G) | 0d:0h:0m:17s | | 2 | 9.4% (4) | 55.5M (512M) | 8.4M (2G) | 0d:0h:0m:17s | +----------+-------------+----------------+--------------+--------------+
  • 40. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases  Cloud Foundry and asynchronous architectures
  • 42. Creating a service instance $ vmc create-service mysql --name mysql1 Creating Service: OK $ vmc services ============== System Services ============== +------------+---------+---------------------------------------+ | Service | Version | Description | +------------+---------+---------------------------------------+ | mongodb | 1.8 | MongoDB NoSQL store | | mysql | 5.1 | MySQL database service | | postgresql | 9.0 | PostgreSQL database service (vFabric) | | rabbitmq | 2.4 | RabbitMQ messaging service | | redis | 2.2 | Redis key-value store service | +------------+---------+---------------------------------------+ =========== Provisioned Services ============ +-------------+---------+ | Name | Service | +-------------+---------+ | mysql1 | mysql | +-------------+---------+
  • 43. Typical Spring application is cloud ready <beans> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" > <property name="driverClassName" ! ! ! value="com.mysql.jdbc.Driver" /> <property name="url" ! value="jdbc:mysql://localhost:3306/cf" /> <property name="username" value="cfuser" /> <property name="password" value="cfpassword" /> … </bean> class SomeClass { @Autowired private DataSource dataSource; }
  • 44. Deploying it $ 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 Would you like to bind any services to 'cer-spring'? [yN]: y 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
  • 45. DataSource bean is reconfigured automatically <beans> <bean id="dataSource" class="…"> … DataSource for MySQL instance … </bean> </beans> class SomeClass { @Autowired private DataSource dataSource; }
  • 47. 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
  • 48. …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>
  • 49. Testing scenario  Create MySQL service instance  Use Caldecott to tunnel database  Populate DB using mysql+sql scripts  Deploy application bound to database  Test the application  …  Delete application and database
  • 50. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases  Cloud Foundry and asynchronous architectures
  • 51. Spring programming model Benefits: •Improved developer productivity •Higher quality code •Portability across Dependency Injection application servers POJO Portable Service Aspect-Oriented Abstractions Programming (Transactions, data access, …) 51
  • 52. Spring is ideal for the cloud environment  Yet another environment for your application to run in • Different Java runtime • Different databases – sometimes not relational!  Dynamic environment: • Servers come and go • IP addresses change  Must integrate with in-house applications: • RPC • Asynchronous messaging  To leverage elasticity your application must be architected to scale up and down • Asynchronous, loose coupling = Problems already solved by the Spring framework
  • 53. Spring 3.1 features for cloud applications 53
  • 54. Spring configuration options Auto-reconfiguration Cloud Foundry Runtime <cloud:*/> namespace CloudEnvironment API VCAP_APPLICATION, VCAP_SERVICES env vars
  • 55. VCAP_APPLICATION { "instance_id": "e53853fe21d5d740aadf7ddcc0670b4e", "instance_index": 0, "name": "cer-spring", "uris": ["cer-spring.cloudfoundry.com"], "users": ["crichardson@vmware.com"], "version": "56892923b974db90a8f6c7120b665fb17cff7edb-1", "start": "2011-12-02 23:06:01 +0000", "runtime": "java", "state_timestamp": 1322867161, "port": 40198, "limits": { "fds": 256, "mem": 536870912, "disk": 2147483648 }, "host": "172.30.50.9"
  • 56. VCAP_SERVICES { "mysql-5.1": [{ "name": "mysql1", "label": "mysql-5.1", "plan": "free", "tags": ["mysql", "mysql-5.1", "relational"], "credentials": { "name": "d7cb8afb52f084f3d9bdc269e7d99ab50", "hostname": "172.30.48.20", "host": "172.30.48.20", "port": 3306, "user": "usmMRfwzyYG53", "username": "usmMRfwzyYG53", "password": "pxWSBVeu80GDp" } }]
  • 57. CloudEnvironment: parses JSON so you don't have to CloudEnvironment env = new CloudEnvironment(); Properties props = env.getCloudProperties(); String prop = props.getProperty( "cloud.services.mysql1.connection.hostname" ); ApplicationInstanceInfo instanceInfo = env.getInstanceInfo(); int port = instanceInfo.getPort(); List<String> urls = instanceInfo.getUris(); …
  • 58. Provides access to ServiceInfo… RdbmsServiceInfo mis = env.getServiceInfo( ! ! "mysql1", ! ! RdbmsServiceInfo.class); String mySqlUrl = mis.getUrl();
  • 59. … which can create DataSources etc @Configuration public class CloudDataSourceConfiguration { @Bean public DataSource dataSource() { CloudEnvironment environment = new CloudEnvironment(); RdbmsServiceInfo mysqlSvc = ! ! environment.getServiceInfo("mysql1", RdbmsServiceInfo.class); ! RdbmsServiceCreator dataSourceCreator = new RdbmsServiceCreator(); DataSource dataSource = dataSourceCreator.createService(mysqlSvc); return dataSource; } } 59
  • 60. <cloud:*/> namespace  Spring XML namespace  Defines beans from CloudEnvironment • Connection factories, e.g. DataSource • Properties
  • 61. <cloud:data-source/> Configures a JDBC DataSource <cloud:data-source id="dataSource" service-name="mysql1"> <cloud:pool pool-size="1-5"/> <cloud:connection properties="charset=utf-8"/> </cloud:data-source> ... @Autowired private DataSource dataSource ; 61
  • 62. <cloud:properties>  Exposes basic information about services that can be consumed with Spring’s property placeholder support  Properties automatically available when deploying Spring 3.1 applications <cloud:properties id="cloudProperties" /> <context:property-placeholder properties-ref="cloudProperties"/> class SomeClass { @Value("${cloud.services.mysql1.connection.hostname}") private String mysqlHost; 62
  • 63. Configuring Cloud Foundry apps is easy BUT How to run on the desktop too?
  • 64. Isolating Cloud Foundry configuration  Use Spring 3.1 profiles  Beans belong to one or more profiles  At runtime, one or active profiles active beans  By default, default profile is active  Activate profiles using • system property: -Dspring.active.profiles=profile1,profile2 • programmatically
  • 65. Using <beans profile=""/> <bean class="org.sf.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource"/> </bean> Outside of Cloud Foundry <beans profile="default"> <bean class="org.a.commons.dbcp.BasicDataSource" id="dataSource"> <property name="url" value="jdbc:mysql://localhost/my_db" /> </bean> </beans> Inside Cloud Foundry <beans profile="cloud"> <cloud:data-source id="dataSource" /> </beans> Profiles available in Spring 3.1 65
  • 66. Using @Profile @Configuration @Profile("default") public class LocalDataSourceConfiguration { @Configuration @Bean @Profile("cloud") public DataSource dataSource() { public class CloudDataSourceConfiguration { } @Bean public DataSource dataSource() { } ! ! … } } 66
  • 67. Application configuration via environment variables $ vmc env-add cf1 PAYMENT_SVC=http://... Adding Environment Variable [PAYMENT_SVC=http://...]: OK Stopping Application: OK Staging Application: OK String value = System.getenv("PAYMENT_SVC") @Value("#{systemEnvironment['PAYMENT_SVC']}") private String envVariable;
  • 68. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases • Why NoSQL? • Using MongoDB • Cloud Foundry and MongoDB  Cloud Foundry and asynchronous architectures
  • 69. Cloud Foundry provides NoSQL-aaS But what’s a NoSQL database? Why would you want to use it? How do you use it? 69
  • 70. Solution: Use NoSQL Benefits • Higher performance • Higher scalability • Richer data-model • Schema-less Drawbacks • Limited transactions • Relaxed consistency • Unconstrained data 70
  • 71. Future = multi-paradigm data storage for enterprise applications e.g. Netflix • RDBMS • SimpleDB • Cassandra • Hadoop/Hbase IEEE Software Sept/October 2010 - Debasish Ghosh / Twitter @debasishg 71
  • 72. Spring Data is here to help For NoSQL databases http://www.springsource.org/spring-data 72
  • 73. What you get  Template classes that hide the boilerplate code, similar to JdbcTemplate  Auto-generated (generic) repositories  Java NoSQL mapping  Cross Store Persistence  Support in Roo and Grails 73
  • 74. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases • Why NoSQL? • Using MongoDB • Cloud Foundry and MongoDB  Cloud Foundry and asynchronous architectures
  • 75. MongoDB  Document-oriented database • JSON-style documents: Lists, Maps, primitives • Schema-less  Transaction = update of a single document  Rich query language for dynamic queries  Very fast  Writes are asynchronous!  Highly scalable and available 75
  • 76. Data model = Binary JSON documents Server Database: Food To Go Collection: Restaurants { "name" : "Sahn Maru", "type" : ”Korean", "serviceArea" : [ "94619", "94618" ], "openingHours" : [ { "dayOfWeek" : "Wednesday", Sequence of "open" : 1730, bytes on disk "close" : 2230 }  fast i/o ], "_id" : ObjectId("4bddc2f49d1505567c6220a0") } 76
  • 77. MongoDB use cases  Use cases • High volume writes • Complex data • Semi-structured data  Who is using it? • Shutterfly, Foursquare • Bit.ly Intuit • SourceForge, NY Times • GILT Groupe, Evite, • SugarCRM 77
  • 78. MongoTemplate Simplifies data access MongoTemplate POJO  DBObject Translates exceptions databaseName mapping userId Password defaultCollectionName writeConcern writeResultChecking save() <<interface>> insert() MongoConvertor remove() updateFirst() write(Object, DBObject) findOne() read(Class, DBObject) find() … uses Mongo MongoMapping (Java Driver class) Converter 78
  • 79. Example entity public class Restaurant { private String id; private String name; private List<MenuItem> menuItems; public Restaurant() { } public class MenuItem { public Restaurant(String name) { private String name; this.name = name; private double price; … } public MenuItem() { } public String getName() { return name; } public MenuItem(String name, public void setName(String name) { double price) { this.name = name; this.name = name; } this.price = price; } …getters and setters… …getters and setters… 79
  • 80. Example data access code @Repository public class RestaurantRepository { @Autowired private MongoTemplate mongoTemplate; public static final String RESTAURANTS_COLLECTION = "restaurants"; public void add(Restaurant restaurant) { mongoTemplate.save(RESTAURANTS_COLLECTION, restaurant); } public List<Restaurant> findRestaurantsByName(String restaurantName) { return mongoTemplate.find(RESTAURANTS_COLLECTION, new Query(where("name").is(restaurantName)), Restaurant.class); } 80
  • 81. Mongo document { "_id" : ObjectId("4d977f55d3fe3119c904e026"), "menuItems" : [ { "name" : "Tandoori Portobello Mushrooms", "price" : 5.5 }, { "name" : "Duck Curry Kerala", "price" : 15 } ], "name" : "Ajanta" } 81
  • 83. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases • Why NoSQL? • Using MongoDB • Cloud Foundry and MongoDB  Cloud Foundry and asynchronous architectures
  • 84. Using Mongo and Redis with Cloud Foundry  Create a service - Mongo or Redis  Bind it to your application  Use <cloud:*/> namespace to access the bound service • when cloud profile is active 84
  • 85. Deploying a Mongo application 85
  • 86. Using the Mongo Application 86
  • 87. NoSQL and Caldecott  Caldecott let’s you tunnel to a NoSQL service  Use Redis CLI • redis-cli • Explore database, adhoc operations • ...  Use Mongo CLI etc • Explore database, adhoc operations • Mongo dump/restore • ... 87
  • 88. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases  Cloud Foundry and asynchronous architectures • Why use messages? • RabbitMQ and Spring AMQP • Using Spring Integration • Using RabbitMQ on Cloud Foundry
  • 89. Cloud Foundry provides RabbitMQ - aaS But what’s RabbitMQ? Why would you want to use it? How do you use it? 89
  • 90. But why messaging? Why RabbitMQ? Application A Application B RabbitMQ Traditional application integration 90
  • 91. Messaging within applications wgrus-billing.war Accounting Service wgrus-inventory.war wgrus-store.war Widget Message InventoryService StoreFront Broker MySQL wgrus-inventory.war Gadget InventoryService Decouples front-end from back-end Front-end continues to work wgrus-shipping.war when back-end is down Shipping Broker smoothes out traffic Service spikes 91
  • 92. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases  Cloud Foundry and asynchronous architectures • Why use messages? • RabbitMQ and Spring AMQP • Using Spring Integration • Using RabbitMQ on Cloud Foundry
  • 93. RabbitMQ – Messaging that Just Works Robust High-performance Easy to use AMQP LEADER
  • 94. Why AMQP? A  Protocol,  not  an  API •A defined set of messaging capabilities called the AMQ model •A network wire-level protocol, AMQP On  commodity  hardware •10-­‐25  thousand  messages  per   second  is  rou7ne  * •The  NIC  is  usually  the   boIleneck *  Non-­‐persistent  messages 17
  • 95. Spring AMQP  Encapsulates low-level details Producer Consumer  Simplifies sending and receiving of messages Amqp Listener Template Container Spring AMQP AMQP
  • 96. Sending AMQP messages @Component public class MessageSender { @Autowired private volatile AmqpTemplate amqpTemplate; public void send(String message) { this.amqpTemplate.convertAndSend( "myExchange", "some.routing.key", message); } public void read() throws Exception { ... String value = amqpTemplate.receiveAndConvert("myQueueName"); ... } 96
  • 97. Spring AMQP is flexible and dynamic BUT It’s very low level 97
  • 98. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases  Cloud Foundry and asynchronous architectures • Why use messages? • RabbitMQ and Spring AMQP • Using Spring Integration • Using RabbitMQ on Cloud Foundry
  • 99. Spring Integration  Builds on Spring framework  High-level of abstraction for building message based applications  Implements EAI patterns  Provides plumbing for exchanging messages between application components  Promotes loosely coupled components  Integrates with external messaging infrastructure: JMS, AMQP, HTTP, Email, File transfer 99
  • 100. Spring Integration concepts  Message channel • Virtual pipe connecting producer and consumer  Message endpoints • The filter of a pipes-and-filter architecture • Read from and/or write to channel  Endpoint types: • Transformer • Filter • Router • Splitter • Aggregator • ServiceActivator • Inbound channel adapter - read from external source, writes to channel • Outbound channel adapter - read from channel write to external destination 100
  • 101. Using Spring Integration with the web store application 101
  • 102. wgrus-store.war wgrus-shipping.war StoreFront Shipping Service Spring Integration RabbitMQ Spring Integration wgrus-billing.war wgrus-inventory.war Credit Service Spring Integration Widget InventoryService Gadget InventoryService 102
  • 103. Store front flow StoreUI object to Message Endpoint orderChannel amqpOut AMQP JSON 103
  • 104. Inventory flow Json to credit check inventory inventory Object to AMQP inventory AMQP Object enricher encricher AMQP Out JSON inventory router credit check credit check Content Based service Router activator Credit Service widget gadget inventory inventory service service 104
  • 105. Shipping flow shipping service Json to AMQP shipping Service Object order Activator channel 105
  • 106. Agenda  Why PaaS?  Cloud Foundry basics  Using Cloud Foundry services  Spring and Cloud Foundry  Using NoSQL databases  Cloud Foundry and asynchronous architectures • Why use messages? • RabbitMQ and Spring AMQP • Using Spring Integration • Using RabbitMQ on Cloud Foundry
  • 107. Rabbit on Cloud Foundry 107
  • 108. Configuring a ConnectionFactory <rabbit:template id="rabbitTemplate" connection-factory="rabbitConnectionFactory"/> <beans profile="default"> ... <rabbit:connection-factory id="rabbitConnectionFactory"/> </beans> <beans profile="cloud"> ... <cloud:rabbit-connection-factory id="rabbitConnectionFactory"/> </beans> 108
  • 109. Using Caldecott with RabbitMQ  Use for JUnit/Integration tests  Run RabbitMQ tools xxxxx xxxxx xxxxx 109
  • 110. Summary  PaaS? Good.  Cloud Foundry? Good.  Spring? Good.  Cloud Foundry and Spring? Really good!  Home work: • Learn Spring: http://www.springframework.org • Learn Spring Data http://www.springframework.org/spring-data • sign up for (free) Cloud Foundry at http://www.cloudfoundry.com • Download the Cloud Foundry Micro Cloud 110
  • 111. @cloudfoundry @crichardson chris.richardson@springsource.com Questions? www.cloudfoundry.com promo code EgyptJUG