cloudfoundry and mongodb, a marriage made in heaven

67
© 2009 VMware Inc. All rights reserved Cloud Foundry and MongoDB, a marriage made in heaven Patrick Chanezon @chanezon Senior Director, Developer Relations VMware Friday, December 9, 11

Upload: patrick-chanezon

Post on 15-May-2015

4.136 views

Category:

Technology


2 download

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

Page 1: 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

Page 2: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 3: CloudFoundry and MongoDb, a marriage made in heaven

3

Spring

Friday, December 9, 11

Page 4: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 5: CloudFoundry and MongoDb, a marriage made in heaven

5

Spring Data

Friday, December 9, 11

Page 6: CloudFoundry and MongoDb, a marriage made in heaven

6

Data Access Challenge #1: Scale Horizontally

Friday, December 9, 11

Page 7: CloudFoundry and MongoDb, a marriage made in heaven

7

Data Access Challenge #2: Heterogeneous data access needs

Friday, December 9, 11

Page 8: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 9: CloudFoundry and MongoDb, a marriage made in heaven

9

NoSQL offers several data store categories

ColumnKey-Value Document Graph

Redis, Riak

Cassandra,HBase

MongoDB Neo4J

Friday, December 9, 11

Page 10: CloudFoundry and MongoDb, a marriage made in heaven

10

NoSQL offers several data store categories

ColumnKey-Value Document Graph

MongoDB (who cares about the rest?)

Friday, December 9, 11

Page 11: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 12: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 13: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 14: CloudFoundry and MongoDb, a marriage made in heaven

14

Spring MongoDB

Friday, December 9, 11

Page 15: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 16: CloudFoundry and MongoDb, a marriage made in heaven

16

Simple Domain Class

Friday, December 9, 11

Page 17: CloudFoundry and MongoDb, a marriage made in heaven

17

Mongo Template

Direct Usage of the Mongo Template:

Friday, December 9, 11

Page 18: CloudFoundry and MongoDb, a marriage made in heaven

17

Mongo Template

Direct Usage of the Mongo Template:

Insert into “Person” Collection

Friday, December 9, 11

Page 19: CloudFoundry and MongoDb, a marriage made in heaven

17

Mongo Template

Direct Usage of the Mongo Template:

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

Friday, December 9, 11

Page 20: CloudFoundry and MongoDb, a marriage made in heaven

17

Mongo Template

Direct Usage of the Mongo Template:

Dropped collection [database.person]

Friday, December 9, 11

Page 21: CloudFoundry and MongoDb, a marriage made in heaven

18

Generic Repository

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

Friday, December 9, 11

Page 22: CloudFoundry and MongoDb, a marriage made in heaven

19

Paging and Sorting Repository

Extends “CrudRepository” Paging and Sorting Repository:

Friday, December 9, 11

Page 23: CloudFoundry and MongoDb, a marriage made in heaven

19

Paging and Sorting Repository

Extends “CrudRepository”

Usage:

Paging and Sorting Repository:

Friday, December 9, 11

Page 24: CloudFoundry and MongoDb, a marriage made in heaven

20

Custom Repository

Custom Repository:

Friday, December 9, 11

Page 25: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 26: CloudFoundry and MongoDb, a marriage made in heaven

21

Cross Store

Friday, December 9, 11

Page 27: CloudFoundry and MongoDb, a marriage made in heaven

22

JPA and MongoDB

JPA “Customer” with a “SurveyInfo” Document

Friday, December 9, 11

Page 28: CloudFoundry and MongoDb, a marriage made in heaven

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Friday, December 9, 11

Page 29: CloudFoundry and MongoDb, a marriage made in heaven

23

Using a Cross-Store

Saving a Customer with a SurveryInfoCreate Customer

Friday, December 9, 11

Page 30: CloudFoundry and MongoDb, a marriage made in heaven

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Create SurveyInfo

Friday, December 9, 11

Page 31: CloudFoundry and MongoDb, a marriage made in heaven

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Assign Survey to Customer

Friday, December 9, 11

Page 32: CloudFoundry and MongoDb, a marriage made in heaven

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Save

Friday, December 9, 11

Page 33: CloudFoundry and MongoDb, a marriage made in heaven

23

Using a Cross-Store

Saving a Customer with a SurveryInfo

Save

Mongo Document:

Friday, December 9, 11

Page 34: CloudFoundry and MongoDb, a marriage made in heaven

24

Cloud Foundry

Friday, December 9, 11

Page 35: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 36: CloudFoundry and MongoDb, a marriage made in heaven

26

Open Source

Friday, December 9, 11

Page 37: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 38: CloudFoundry and MongoDb, a marriage made in heaven

28

Multi Cloud

Friday, December 9, 11

Page 39: CloudFoundry and MongoDb, a marriage made in heaven

29

CloudFoundry.COM

Runtimes & Frameworks

Services

vCenter / vSphere

Cloud Foundry

Infrastructure

Friday, December 9, 11

Page 40: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 41: CloudFoundry and MongoDb, a marriage made in heaven

Micro Cloud Foundry

31

Micro

Friday, December 9, 11

Page 42: CloudFoundry and MongoDb, a marriage made in heaven

What is a Micro Cloud?

32

Entire Cloud Running inside of a single VM

Or

Friday, December 9, 11

Page 43: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 44: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 45: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 46: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 47: CloudFoundry and MongoDb, a marriage made in heaven

Other Cloud Foundry powered PaaS

36

Private PaaS

Added Python and Perl

Public PaaS

Added PHP

Friday, December 9, 11

Page 48: CloudFoundry and MongoDb, a marriage made in heaven

37

Services

Friday, December 9, 11

Page 49: CloudFoundry and MongoDb, a marriage made in heaven

Current Services Available on Cloud Foundry

38

Friday, December 9, 11

Page 50: CloudFoundry and MongoDb, a marriage made in heaven

Service Creation and Binding

39

App Instance

Friday, December 9, 11

Page 51: CloudFoundry and MongoDb, a marriage made in heaven

Service Creation and Binding

39

App Instance Redis Service

Friday, December 9, 11

Page 52: CloudFoundry and MongoDb, a marriage made in heaven

Service Creation and Binding

39

App Instance Redis Service

Friday, December 9, 11

Page 53: CloudFoundry and MongoDb, a marriage made in heaven

Service Creation and Binding

39

App Instance Redis Service

MongoDB

Service

Friday, December 9, 11

Page 54: CloudFoundry and MongoDb, a marriage made in heaven

40

Development LifeCycle

Friday, December 9, 11

Page 55: CloudFoundry and MongoDb, a marriage made in heaven

Traditional App Deploy and Request/Response

Web

App

DB

Web

App

DB

Request/AllocateBuild/SetupInstall/ConfigureDeploy/Test

Scale?Upgrade?Update?

Friday, December 9, 11

Page 56: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 57: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 58: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 59: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 60: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 61: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 62: CloudFoundry and MongoDb, a marriage made in heaven

47

Setting up Cloud Foundry Demo

Friday, December 9, 11

Page 63: CloudFoundry and MongoDb, a marriage made in heaven

Caldecott: tunnelling to Cloud Foundry services

48

Friday, December 9, 11

Page 64: CloudFoundry and MongoDb, a marriage made in heaven

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

Page 65: CloudFoundry and MongoDb, a marriage made in heaven

Accessing Services Bound to Cloud Foundry (consumption)

50

@Inject private Mongo mongo ;

@Inject private MongoTemplate mongoTemplate;

Friday, December 9, 11

Page 66: CloudFoundry and MongoDb, a marriage made in heaven

51

Cloud Foundry MongoDB Demo

Friday, December 9, 11

Page 67: CloudFoundry and MongoDb, a marriage made in heaven

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