CloudFoundry and MongoDb, a marriage made in heaven

Post on 15-May-2015

4.134 views 2 download

Tags:

description

This talk will provide an overview of the PaaS (Platform as a Service) landscape, and will describe the Cloud Foundry open source PaaS, with its multi-framework, multi-service, multi-cloud model. Cloud Foundry allows developers to provision apps in Java/Spring, Ruby/Rails, Ruby/Sinatra, Javascript/Node, and leverage services like MySQL, MongoDB, Reddis, Postgres and RabbitMQ. It can be used as a public PaaS on CloudFoundry.com and other service providers (ActiveState, AppFog), to create your own private cloud, or on your laptop using the Micro Cloud Foundry VM. Micro Cloud Foundry is a very easy way for developers to start working on their application using their framework of choice and MongoDB, without the need to setup a development environment, and your app is one command line away (vmc push) from deployment to cloudfoundry.com.

Transcript of CloudFoundry and MongoDb, a marriage made in heaven

© 2009 VMware Inc. All rights reserved

Cloud Foundry and MongoDB, a marriage made in heaven Patrick Chanezon@chanezonSenior Director, Developer RelationsVMware

Friday, December 9, 11

P@ in a nutshell

• French, based in San Francisco

• Senior Director, Developer Relations, VMware

• Software Plumber, API guy, mix of Enterprise and Consumer

• 18 years writing software, backend guy with a taste for javascript

• 2 y Accenture (Notes guru), 3 y Netscape/AOL (Servers, Portals), 5 y Sun (ecommerce, blogs, Portals, feeds, open source)

• 6 years at Google, API guy (first hired, helped start the team)

• Adwords, Checkout, Social, HTML5, Cloud

Friday, December 9, 11

3

Spring

Friday, December 9, 11

Spring’s aim:

bring simplicity to java development

4

web tier &

RIAservice tier batch

processing

integration &

messaging

data access

/ NoSQL / Big Data

mobile

tc ServerTomcatJetty

lightweightCloudFoundry

VMForce Google App Engine

Amazon Web Services

the cloud: WebSphereJBoss ASWebLogic

(on legacy versions, too!)

traditional

The Spring framework

Friday, December 9, 11

5

Spring Data

Friday, December 9, 11

6

Data Access Challenge #1: Scale Horizontally

Friday, December 9, 11

7

Data Access Challenge #2: Heterogeneous data access needs

Friday, December 9, 11

8

New demands on data access

•... until we needed inexpensive horizontal scaling for some large web based applications ...•... and we needed to deploy our apps in the cloud ...

* image courtesy of Bitcurrent

Friday, December 9, 11

9

NoSQL offers several data store categories

ColumnKey-Value Document Graph

Redis, Riak

Cassandra,HBase

MongoDB Neo4J

Friday, December 9, 11

10

NoSQL offers several data store categories

ColumnKey-Value Document Graph

MongoDB (who cares about the rest?)

Friday, December 9, 11

11

Spring Frameworkbuilt-in data access support

•Transaction abstractions•Common data access exception hierarchy•JDBC - JdbcTemplate•ORM - Hibernate, JPA support•OXM - Object to XML mapping•Serializer/Deserializer strategies (Spring 3.0)•Cache support (Spring 3.1)

Friday, December 9, 11

12

•Spring Data Key-value•Spring Data Document•Spring Data Graph•Spring Data Column•Spring Data Blob•Spring Data JPA Repository / JDBC Extensions•Spring Gemfire / Spring Hadoop ...•Grails iNcOnSeQuentiaL

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

Friday, December 9, 11

13

Spring Data Building Blocks

•Low level data access APIs✓MongoTemplate, RedisTemplate ...•Object Mapping (Java and GORM)•Cross Store Persistence Programming model•Generic Repository support •Productivity support in Roo and Grails

Friday, December 9, 11

14

Spring MongoDB

Friday, December 9, 11

15

Spring Data Document Mongo

•MongoTemplate•MongoConverter interface for mapping Mongo documents•SimpleMongoConverter for basic POJO mapping support•Leverage Spring 3.0 TypeConverters and SpEL•Exception translation•Advanced Mapping•Annotation based (@Document, @Id, @DbRef)•MongoRepository•Built on Hades support for JPA Repositories

Friday, December 9, 11

16

Simple Domain Class

Friday, December 9, 11

17

Mongo Template

Direct Usage of the Mongo Template:

Friday, December 9, 11

17

Mongo Template

Direct Usage of the Mongo Template:

Insert into “Person” Collection

Friday, December 9, 11

17

Mongo Template

Direct Usage of the Mongo Template:

findOne using query: { "name" : "Joe"} in db.collection: database.Person

Friday, December 9, 11

17

Mongo Template

Direct Usage of the Mongo Template:

Dropped collection [database.person]

Friday, December 9, 11

18

Generic Repository

Interface for generic CRUD operations on a repository for a specific type

Friday, December 9, 11

19

Paging and Sorting Repository

Extends “CrudRepository” Paging and Sorting Repository:

Friday, December 9, 11

19

Paging and Sorting Repository

Extends “CrudRepository”

Usage:

Paging and Sorting Repository:

Friday, December 9, 11

20

Custom Repository

Custom Repository:

Friday, December 9, 11

20

Custom Repository

Custom Repository:

Keyword Sample Logical result

GreaterThan findByAgeGreaterThan(int age) {"age" : {"$gt" : age}}

LessThan findByAgeLessThan(int age) {"age" : {"$lt" : age}}

Between findByAgeBetween(int from, int to) {"age" : {"$gt" : from, "$lt" : to}}

NotNull findByFirstnameNotNull() {”firstname" : {"$ne" : null}}

Null findByFirstnameNull() {”firstname" : null}

Like findByFirstnameLike(String name) "firstname" : firstname} (regex)

Keywords :

Friday, December 9, 11

21

Cross Store

Friday, December 9, 11

22

JPA and MongoDB

JPA “Customer” with a “SurveyInfo” Document

Friday, December 9, 11

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Friday, December 9, 11

23

Using a Cross-Store

Saving a Customer with a SurveryInfoCreate Customer

Friday, December 9, 11

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Create SurveyInfo

Friday, December 9, 11

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Assign Survey to Customer

Friday, December 9, 11

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Save

Friday, December 9, 11

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Save

Mongo Document:

Friday, December 9, 11

24

Cloud Foundry

Friday, December 9, 11

Cloud Foundry: The Open PaaS

25

Clou

d Pr

ovide

r Int

erfa

ce

Application Service Private Clouds

PublicCloud

MicroCloud

Data Services

Other Services

Msg Services

vFabric Postgres

vFabric RabbitMQTM

• Open Source: Apache 2 Licensed

• multi language/frameworks

• multi services

• multi cloud

Friday, December 9, 11

26

Open Source

Friday, December 9, 11

Open Source Advantage

§ http://code.google.com/p/googleappengine/issues/detail?id=13

27

• https://github.com/cloudfoundry/vcap/pull/25

Friday, December 9, 11

28

Multi Cloud

Friday, December 9, 11

29

CloudFoundry.COM

Runtimes & Frameworks

Services

vCenter / vSphere

Cloud Foundry

Infrastructure

Friday, December 9, 11

30

Cloud Foundry.ORG

The Source Code to Compile & Build Cloud Foundry

vCenter / vSphere

Cloud Foundry

Download

Code

Setup Environment

Deploy Behind Firewall

Setup Scripts

Friday, December 9, 11

Micro Cloud Foundry

31

Micro

Friday, December 9, 11

What is a Micro Cloud?

32

Entire Cloud Running inside of a single VM

Or

Friday, December 9, 11

Micro Cloud Foundry… (BETA)

33

A pre-built Micro (Single VM) version of Cloud Foundry…

Signup @ http://cloudfoundry.com/micro

You need a Cloud Foundry.com Account to use Micro Cloud Foundry

Friday, December 9, 11

Micro Cloud Foundry… (BETA)

33

A pre-built Micro (Single VM) version of Cloud Foundry…

Signup @ http://cloudfoundry.com/micro

You need a Cloud Foundry.com Account to use Micro Cloud Foundry

Micro

Friday, December 9, 11

Pre-requisites

34

Resources

Virtualization

Clients

Minimum 1 GB

RAM

Minimum 8 GB

Disk

Internet Connectivity

(w/DHCP is ideal)

VMC STSCommand line GUI

Friday, December 9, 11

What is in Micro Cloud Foundry?

35

Open source Platform as a Service project

App Instances Services

10.04

Dynamic Updating DNS

.COM

Friday, December 9, 11

Other Cloud Foundry powered PaaS

36

Private PaaS

Added Python and Perl

Public PaaS

Added PHP

Friday, December 9, 11

37

Services

Friday, December 9, 11

Current Services Available on Cloud Foundry

38

Friday, December 9, 11

Service Creation and Binding

39

App Instance

Friday, December 9, 11

Service Creation and Binding

39

App Instance Redis Service

Friday, December 9, 11

Service Creation and Binding

39

App Instance Redis Service

Friday, December 9, 11

Service Creation and Binding

39

App Instance Redis Service

MongoDB

Service

Friday, December 9, 11

40

Development LifeCycle

Friday, December 9, 11

Traditional App Deploy and Request/Response

Web

App

DB

Web

App

DB

Request/AllocateBuild/SetupInstall/ConfigureDeploy/Test

Scale?Upgrade?Update?

Friday, December 9, 11

Web

How Apps are Deployed on Cloud Foundry

Web

App

DB

“vmc push MyApp”

WebApp

DB

“vmc instances MyApp 5”“vmc map MyApp MyApp2”“vmc update MyApp”

Scale?Upgrade?Update?

Friday, December 9, 11

Web

How Apps are Deployed on Cloud Foundry

Web

App

DB

“vmc push MyApp”

WebApp

DB

“vmc instances MyApp 5”“vmc map MyApp MyApp2”“vmc update MyApp”

Scale?Upgrade?Update?

Friday, December 9, 11

How Apps are Accessed on Cloud Foundry

Web

App

DB

App Instance

Service

Request Web InterfaceLoad

Balancingand

Routing

Response

“vmc push MyApp”

Friday, December 9, 11

How Apps are Scaled on Cloud Foundry

Web

App

DB

App Instances

Service

Request

Response

Load

Balancer(s)Load

Balancer(s)

Load Balancing

and Routing

Web

App

Web

App

“vmc instances MyApp 3”

Friday, December 9, 11

How Apps are Updated on Cloud Foundry

Web

App

DB

Service

Web

App

DB

Service

Web

App

Web

App

PreviousVersion

InstanceStopped

UpdatedCode

NewVersion

“vmc update MyApp”

Friday, December 9, 11

At Scale – Multi-Node Distributed App

46 10

rabbitMQ

redis mysql

system load balancer

elastic pool

front_end front_end

elastic pool

back_end

mongodb

Friday, December 9, 11

47

Setting up Cloud Foundry Demo

Friday, December 9, 11

Caldecott: tunnelling to Cloud Foundry services

48

Friday, December 9, 11

Accessing Services Bound to Cloud Foundry (producer)

49

private String mongoDatabaseServiceName = "survey-mongo";

@Beanpublic CloudEnvironment cloudEnvironment() { return new CloudEnvironment();}

@Beanpublic MongoServiceInfo mongoServiceInfo() { return cloudEnvironment().getServiceInfo( mongoDatabaseServiceName, MongoServiceInfo.class);}

@Beanpublic MongoDbFactory mongoDbFactory() { MongoServiceCreator msc = new MongoServiceCreator(); MongoDbFactory db = msc.createService(mongoServiceInfo());}

Friday, December 9, 11

Accessing Services Bound to Cloud Foundry (consumption)

50

@Inject private Mongo mongo ;

@Inject private MongoTemplate mongoTemplate;

Friday, December 9, 11

51

Cloud Foundry MongoDB Demo

Friday, December 9, 11

Where to Find More

§ Spring Data Project: http://bit.ly/spring-data

§ CloudFoundry Samples: http://bit.ly/cloudfoundry-samples

§ MicroCloud Foundry for Spring Developershttp://bit.ly/mcf4spring

§ Spring Data Mongo on Cloud Foundry (webinar, 12/01/2011)

§ http://bit.ly/spring-mongo-cloudfoundry

52

Friday, December 9, 11