decomposing applications for scalability and deployability (april 2012)

92
Decomposing applications for deployability and scalability Chris Richardson Author of POJOs in Action Founder of the original CloudFoundry.com @crichardson [email protected] 1

Upload: chris-richardson

Post on 08-May-2015

11.426 views

Category:

Technology


0 download

DESCRIPTION

Today, there are several trends that are forcing application architectures to evolve. Users expect a rich, interactive and dynamic user experience on a wide variety of clients including mobile devices. Applications must be highly scalable, highly available and run on cloud environments. Organizations often want to frequently roll out updates, even multiple times a day. Consequently, it’s no longer adequate to develop simple, monolithic web applications that serve up HTML to desktop browsers. In this talk we describe the limitations of a monolithic architecture. You will learn how to use the scale cube to decompose your application into a set of narrowly focused, independently deployable back-end services and an HTML 5 client. We will also discuss the role of technologies such as NodeJS and AMQP brokers. You will learn how a modern PaaS such as Cloud Foundry simplifies the development and deployment of this style of application.

TRANSCRIPT

Page 1: Decomposing Applications for Scalability and Deployability (April 2012)

Decomposing applications for deployability and scalability

Chris Richardson

Author of POJOs in ActionFounder of the original CloudFoundry.com

@[email protected]

1

Page 2: Decomposing Applications for Scalability and Deployability (April 2012)

Presentation goal

2

Decomposing applications to improve deployability and scalability

and How Cloud Foundry helps

Page 3: Decomposing Applications for Scalability and Deployability (April 2012)

About Chris

3

Page 4: Decomposing Applications for Scalability and Deployability (April 2012)

(About Chris)

4

Page 5: Decomposing Applications for Scalability and Deployability (April 2012)

About Chris()

5

Page 6: Decomposing Applications for Scalability and Deployability (April 2012)

About Chris

6

Page 7: Decomposing Applications for Scalability and Deployability (April 2012)

About Chris

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

7

Page 8: Decomposing Applications for Scalability and Deployability (April 2012)

vmc push About-Chris

8

Developer Advocate for CloudFoundry.com

Signup at http://cloudfoundry.com

Promo code: CFOpenTour2012

Page 9: Decomposing Applications for Scalability and Deployability (April 2012)

9

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

Page 10: Decomposing Applications for Scalability and Deployability (April 2012)

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

10

Page 11: Decomposing Applications for Scalability and Deployability (April 2012)

Tomcat

Traditional web application architecture

11

Browser

WAR

MySQL Database

developtestdeployscale

ShippingService

AccountingService

InventoryService

StoreFrontUI

Simple to

Apache

Page 12: Decomposing Applications for Scalability and Deployability (April 2012)

But there are problems

12

Page 13: Decomposing Applications for Scalability and Deployability (April 2012)

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

13

Java Web Application

Browser

HTTP Request

HTML/Javascript

Old style UI architecture isn’t good enough

Real-time web ≅ NodeJS

Page 14: Decomposing Applications for Scalability and Deployability (April 2012)

One dimensional scalability

14

§ Scales to handle transaction volumes§ Higher transaction rate required ⇒ run more instances§ Some clouds will do this automatically, others easily§ No code changes required

BUT§ Does not scale with increasing data volumes§ Caching is less effective§ Requires more memory§ Requires more I/O

Page 15: Decomposing Applications for Scalability and Deployability (April 2012)

Components that don’t cluster§ Most application components are easily clustered:•Most services are stateless•Server-side session state: sticky session routing/state

server

BUT there are exceptions

§ Singletons that maintain global application state:• e.g. CEP engine analyzing event stream over HTTP

§ Commercial software with a per-server license fee

§ If one application component can’t be clustered ⇒ you can’t cluster the application!

15

Page 16: Decomposing Applications for Scalability and Deployability (April 2012)

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

Fear of change

§ Updates will happen less often§ e.g. Makes A/B testing UI really difficult 16

Page 17: Decomposing Applications for Scalability and Deployability (April 2012)

Large application

Slow IDESlow start times for web container

17

Page 18: Decomposing Applications for Scalability and Deployability (April 2012)

Scaling development

18

!=Scalable development

WAR

Shipping

Accounting

InventoryService

StoreFrontUI

§ Forces teams to synchronize development efforts§ Teams need to coordinate updates

Page 19: Decomposing Applications for Scalability and Deployability (April 2012)

Long-term commitment to a single technology stack§ Let’s suppose you go with the JVM•Some polyglot support•Many (but not all) JVM languages interoperate easily• e.g. Scala, Groovy modules within a Java application•But you can’t use non-JVM languages

§ Application depends on a particular:•Framework - e.g. Spring or Java EE•Container - e.g. Tomcat

§ Switching technology stack ⇒ touches entire application•Painful•Rarely done

19

Page 20: Decomposing Applications for Scalability and Deployability (April 2012)

20

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

Page 21: Decomposing Applications for Scalability and Deployability (April 2012)

3 dimensions to scaling

21

X axis - horizontal duplicationZ ax

is - d

ata pa

rtitio

ning

Y axis - functionaldecomposition

Scale by cloning

Scale

by sp

litting

simila

r thin

gsScale by splitting different things

Page 22: Decomposing Applications for Scalability and Deployability (April 2012)

X axis scaling - application level

22

Tomcat

Load Balancer

WAR

Page 23: Decomposing Applications for Scalability and Deployability (April 2012)

X axis scaling - database level

23

MySQL Master

MySQL Slave 1

MySQL Slave 2

MySQL Slave N

Writes Consistent reads

Inconsistent reads

Slaves are clones

Page 24: Decomposing Applications for Scalability and Deployability (April 2012)

Benefits and drawbacks of X axis splits§ Benefits•Easy and fast to implement•Handles increasing transaction volumes•Simple to manage

§ Drawbacks•Doesn’t scale with increasing data volumes•Doesn’t address application/development complexity•Couples entire application to a particular technology stack

24

Page 25: Decomposing Applications for Scalability and Deployability (April 2012)

Z axis scaling - data partitioning§ Each server runs the identical code base § Different servers responsible for different data§ Route request based on•Attribute of the request• Identity/attribute of the requestor/customer

§ For example:•Sharding - partition data by primary key•Free customer vs. paying customer

25

“Router”

Server 1

Server 2

...

Request:... Some attribute ...

Page 26: Decomposing Applications for Scalability and Deployability (April 2012)

Database server 2

Z axis scaling - database sharding

26

ID Name …

1 Ajanta

2 Eggshop

Partition column

RESTAURANT table

ID Name …

1 Ajanta

ID Name …

2 Eggshop

Database server 1

X axis scaling too!

Page 27: Decomposing Applications for Scalability and Deployability (April 2012)

Search ServiceSearch Service

Z axis scaling - application example

27

Database server 2Database server 1

Search Service Search Service

Query AggregatorUpdate Router

QueryContent

Cache Cache

Partition 1 Partition 2

Page 28: Decomposing Applications for Scalability and Deployability (April 2012)

Benefits and drawbacks of Z axis splits§ Benefits•Each server only deals with a subset of the data• Improved caching•Reduced memory usage and reduced I/O• Improved transaction scalability• Improved fault isolation - failure only makes part of the data

inaccessible§ Drawbacks•Doesn’t scale with increasing development and application

complexity• Increased management/deployment complexity

28

Page 29: Decomposing Applications for Scalability and Deployability (April 2012)

Y axis scaling - functional partitioning§ Splits monolithic application into a set of services§ Each service implements related set of functionality§ Partitioning schemes:•Partition functionality by noun or by verb•Single Responsibility Principle• e.g. Unix utilities - do one focussed thing well

29

Page 30: Decomposing Applications for Scalability and Deployability (April 2012)

ShippingService

AccountingService

billing web application

shipping web application

InventoryService

inventory web application

30

Y axis scaling - application level

Store Front

Store front web application

Apply X axis cloning and/or Z axis partitioning to each service

Page 31: Decomposing Applications for Scalability and Deployability (April 2012)

MySQL MySQL

Y axis scaling - databases

31

MySQL

Order table

....

MySQL

Customer table

....

Apply X axis cloning and/or Z axis partitioning to each database

Application

Page 32: Decomposing Applications for Scalability and Deployability (April 2012)

Real world examples

32

http://highscalability.com/amazon-architecture

Between 100-150 services are accessed to build a page.

http://techblog.netflix.com/

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

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

Page 33: Decomposing Applications for Scalability and Deployability (April 2012)

Benefits and drawbacks of Y axis splits§ Benefits•Scales development: focussed two pizza devops teams•Deploy services independently•Scale services independently• Improves fault isolation•Eliminates long-term commitment to a single technology

stack•Enforces well defined interfaces between components

§ Drawbacks• Implementation complexity•Deployment complexity

33

Page 34: Decomposing Applications for Scalability and Deployability (April 2012)

Two levels of architecture§ System level•Defines the inter-service glue: interfaces and

communication mechanisms•Slow changing

§ Service level•Defines the internal architecture of each service•Far fewer constraints on technology•Each service could use a different technology stack•Rapid evolving

34

Versus

Page 35: Decomposing Applications for Scalability and Deployability (April 2012)

If services are small...§ Regularly rewrite using a better technology stack§ Pick the best developers rather than best <pick a

language> developers§ Adapt system to changing requirements and better

technology without a total rewrite

35

Fred George “Developer Anarchy”

Page 36: Decomposing Applications for Scalability and Deployability (April 2012)

Moreover: you are not the same you ...§ Cell lifetimes:• hours - some white blood cells• days - stomach lining cells• years - bone cells• lifetime - brain cells

§ 50 to 70 billion of your cells die each day§ Yet you (the system) remains intact

36

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

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

Can we build software systems with these

characteristics?

Too much technical debt ⇒ component death?

Page 37: Decomposing Applications for Scalability and Deployability (April 2012)

37

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

Page 38: Decomposing Applications for Scalability and Deployability (April 2012)

Inter-service communication options§ Multiple collaborating services ⇒ need a communication

mechanism§ Many choices:•Synchronous ⇔ asynchronous•Transports: HTTP, AMQP, ...•Formats: JSON, XML, Protocol Buffers, Thrift, ...•Even via the database

§ Distributed application ⇒ error handling strategies

38

Page 39: Decomposing Applications for Scalability and Deployability (April 2012)

ShippingService

StoreFrontUI

wgrus-store.war

AccountingService

wgrus-billing.war

wgrus-shipping.war

InventoryService

wgrus-inventory.war

MySQL

39

REST

SOAP

Thrift

...

Synchronous communication

Lots of choices

Page 40: Decomposing Applications for Scalability and Deployability (April 2012)

Service discovery options§ Clients need to know the coordinates of their dependencies

§ Option #1: Caller is configured with dependencies’s URL• e.g. Environment variables, system properties

§ Option #2: Services announce their location•Relies on ‘broadcast’ protocol or Gossip protocol to

announce location• e.g. RabbitMQ message broker

§ Option #3: configuration server•Maintains all the configuration information• e.g. Zookeeper

40

Page 41: Decomposing Applications for Scalability and Deployability (April 2012)

Benefits and drawbacks§ Benefits•Simple to implement and use

§ Drawbacks•Poor fault isolation: caller is blocked if server is down/slow•Caller needs to know server’s coordinates (URL, ...)• Less scalable than asynchronous protocols

41

Page 42: Decomposing Applications for Scalability and Deployability (April 2012)

StoreFrontUI

wgrus-store.war

AccountingService

wgrus-billing.war

WidgetInventoryService

wgrus-inventory.war

InventoryService

wgrus-inventory.war

MySQL

42

RabbitMQ(Message Broker)

Asynchronous message-based communication

Page 43: Decomposing Applications for Scalability and Deployability (April 2012)

Benefits and drawbacks§ Benefits•Decouples caller from server•Caller unaware of server’s coordinates (URL)•Message broker buffers message when server is down/slow

§ Drawbacks•Additional complexity of message broker •RPC using messaging is more complex

43

Page 44: Decomposing Applications for Scalability and Deployability (April 2012)

Shared databases?

44

Order Management Customer Management

Database

OrdersCustomers

Page 45: Decomposing Applications for Scalability and Deployability (April 2012)

Benefits and drawbacks

45

§ Benefits•Simple•Single (consistent) source of data

§ Drawbacks•Defeats the purpose of having multiple services• Less scalable•More coupling

Page 46: Decomposing Applications for Scalability and Deployability (April 2012)

Better: separate databases

46

Order Management Customer Management

Database

OrdersCustomers (copy)

Database

Customers

Customer Update Event

Page 47: Decomposing Applications for Scalability and Deployability (April 2012)

Maintaining consistency without 2PC

47

begin transaction update order tables save intent to update customer tablescommit transaction

for each saved intent begin transaction delete intent queue message to update customer commit transaction

BASE: An Acid Alternative by Dan Pritchetthttp://queue.acm.org/detail.cfm?id=1394128

dequeue messagebegin transaction if (update has not been applied) { record update as applied update customer tables } commit transaction acknowledge message

Order management

Customer management

Page 48: Decomposing Applications for Scalability and Deployability (April 2012)

Writing code that calls services

48

Page 49: Decomposing Applications for Scalability and Deployability (April 2012)

Composable futures§ Problem:•Service A needs to call services B and C and then D•Makes sense to call B and C parallel•Yet most concurrency APIs are low-level, error-prone etc

§ Solution:•Use Akka composable futures = really nice abstraction

49

val futureB = callB()val futureC = callC()

val futureD = for { b <- futureB.mapTo[SomeType] c <- futureC.mapTo[SomeType] d <- callD(b, c) } yield d

val result = Await.result(futureD, 1 second). asInstanceOf[SomeOtherType]

http://doc.akka.io/docs/akka/2.0.1/scala/futures.htmlhttp://en.wikipedia.org/wiki/Futures_and_promises

Two calls execute in parallel

And then invokes D

Get the result of D

Page 50: Decomposing Applications for Scalability and Deployability (April 2012)

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

50

Page 51: Decomposing Applications for Scalability and Deployability (April 2012)

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

51

Page 52: Decomposing Applications for Scalability and Deployability (April 2012)

Spring Integration insulates components from the underlying

communication mechanism

52

Page 53: Decomposing Applications for Scalability and Deployability (April 2012)

Order Service

Messaging Gateway

Channel Service Activator

Shipping service

53

Example of reconfigurability - local@Servicepublic class OrderServiceImpl {

@Autowiredprivate ShippingService shippingService;

public void placeOrder() { String orderId = generateOrderId(); … shippingService.shipOrder(orderId);}

}

@Servicepublic class ShippingServiceImpl {

public void shipOrder(String orderId) { System.out.println("shipped order: " + orderId);}

}

Page 54: Decomposing Applications for Scalability and Deployability (April 2012)

Order Service

Messaging Gateway

Channel Service Activator

Shipping service

AMQP

RabbitMQ

AMQP Channel

54

Example of reconfigurability - distributed

Code unchanged in new deployment

Page 55: Decomposing Applications for Scalability and Deployability (April 2012)

Handling failure§ Errors happen (especially in distributed systems)§ Use timeouts and retries•Never wait forever•Some errors are transient so retry

§ Use per-dependency bounded thread pool with bounded queue• Limits number of outstanding requests•Fails fast if service is slow or down

§ Use circuit breaker•High rate of errors ⇒ stop calling temporarily •Avoids calling service that has issues

§ On failure•Returned cached or default data• Invoke custom error handler

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

Page 56: Decomposing Applications for Scalability and Deployability (April 2012)

56

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

Page 57: Decomposing Applications for Scalability and Deployability (April 2012)

Modular application

Choice of presentation layer technology+

Redeploy UI frequently/independently

57

Page 58: Decomposing Applications for Scalability and Deployability (April 2012)

NodeJS is the fashionable technology

58

Many JavaScript client frameworks have a NodeJS counterparte.g. socket.io

Page 59: Decomposing Applications for Scalability and Deployability (April 2012)

NodeJS isn’t the only game in town

59

JVM-based http://vertx.io/

Page 60: Decomposing Applications for Scalability and Deployability (April 2012)

A modern web application

60

Browser

Service 1

Service 2

...

HTML 5Application

Socket.ioclient

Events

RESTful WS

Server Application

Socket.ioserver

Node JS

Page 61: Decomposing Applications for Scalability and Deployability (April 2012)

Alternatively: multiple front-end servers

61

Browser

Node JS Service 1

Service 2

...

HTML 5Application

Node JS

Node JS

Needs single-sign-on

Page 62: Decomposing Applications for Scalability and Deployability (April 2012)

NodeJS - using RESTful WS and AMQP

62

Node JS

Service

RabbitMQ Service

REST

AMQP AMQP

Requests

Eventssocket.io

Page 63: Decomposing Applications for Scalability and Deployability (April 2012)

Updating the UI is easy

63

§ Update the UI independently of rest of system§ Easily run A/B tests § Enables fast iteration of the UI

http://theleanstartup.com/principles

Page 64: Decomposing Applications for Scalability and Deployability (April 2012)

But coordination with backend changes required§ Let’s imagine that you are deploying an advanced search

feature:•Enhancements to search service•Enhancements to UI

§ Before•Deploy new war

§ Now:•Some coordination required•Deploy updated backend service•Deploy updated NodeJS and browser code•Enable feature using feature switch

64

Page 65: Decomposing Applications for Scalability and Deployability (April 2012)

65

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

Page 66: Decomposing Applications for Scalability and Deployability (April 2012)

The challenge§ In the beginning:• It would be easy to use Y axis/functional decomposition•But you don’t need it and it would slow you down

§ Later on:•You do need it•But your application logic is tangled and decomposition is

difficult

66

Page 67: Decomposing Applications for Scalability and Deployability (April 2012)

Lower cost way to start with Y axis decomposition§ Enforce boundaries between services, e.g. DTOs§ But run in a single JVM with a single database§ Use Spring Integration•Course-grained message-based communication•Via in-memory channels

§ Downside:• Implementing the glue layers are extra work

67

Page 68: Decomposing Applications for Scalability and Deployability (April 2012)

Application

Special case: Components that don’t cluster

68

Monitoring

Esper

Rest of domain classes

AC

D

B

Doesn’t cluster ⇒ No X axis scaling/cloning

Tangled dependencies prevent Y axis scaling

Page 69: Decomposing Applications for Scalability and Deployability (April 2012)

Don’t let this happen!

Use well-defined interfaces

Ensure loose coupling

69

Page 70: Decomposing Applications for Scalability and Deployability (April 2012)

Monolithic application

Traditional application architecture

70

Service A Service B Service C

Shared domain model

A C

B

X Z

Y

Difficult to untangle

Page 71: Decomposing Applications for Scalability and Deployability (April 2012)

Service

Domain model 2

Application

Extracting a service = untangling dependencies

71

Service A Service BService C

Domain model 1

A C

B

X

Z

Y

Trouble!

Page 72: Decomposing Applications for Scalability and Deployability (April 2012)

Untangling dependencies

72

§ Domain object is part of an association•Read only - replicate•Update only - notification interface•Update then read - replicate

§ Domain object is a request parameter•Read-only - replace with DTO•Update only - notification interface•Update then read - tricky

§ Note - Need acyclic dependencies• If used object isn’t part of a service = assumption is that it

belongs in calling service

class A { private B other;}

class A { void m(B other) { ... }}

Page 73: Decomposing Applications for Scalability and Deployability (April 2012)

Bounded context is a useful idea§ Different parts of a system ⇒ different domain models§ Different services have a different view of some domain

objects, e.g.•User Management = complex view of user•Rest of application = PK + ACL + Name

§ Different services can have a different domain model§ Services exchange messages to synchronize data

73

Page 74: Decomposing Applications for Scalability and Deployability (April 2012)

Domain model 2

Untangling dependencies 1

74

Domain model 1

A C

B

X

Z

Y

doSomething(Y)

getSomething()

doSomethingElse()

Service A Service B Service C

Page 75: Decomposing Applications for Scalability and Deployability (April 2012)

Domain model 2

Untangling dependencies 2

75

Domain model 1

A C

B

X

Z

Y

doSomething(YDTO)

doSomethingElse()

Facade A

Facade B

Service A Service B Service C

Page 76: Decomposing Applications for Scalability and Deployability (April 2012)

Domain model 2

Untangling dependencies 3

76

Domain model 1

A

C

B

X

Z

Y

doSomething(YDTO)

doSomethingElse()

Facade A

Facade B

Message Broker Listener

Listener

Service A Service B Service C

Page 77: Decomposing Applications for Scalability and Deployability (April 2012)

77

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

Page 78: Decomposing Applications for Scalability and Deployability (April 2012)

Traditional tools: monolithic applications

78

Page 79: Decomposing Applications for Scalability and Deployability (April 2012)

Developing service-oriented apps is harder§ Many more moving parts to manage• Infrastructure services: SQL, NoSQL, RabbitMQ•Application services

§ Who is going to setup the environments:• the developer sandbox?• ...•QA environments?

79

Page 80: Decomposing Applications for Scalability and Deployability (April 2012)

Cloud Foundry makes it easier§ Easy to deploy applications§ Easy to provision services§ Manifest describes the structure of a set of services§ vmc env-add for binding 'app services' together§ Micro Cloud Foundry is your personal cloud/sandbox§ Caldecott exposes services for use by integration tests

80

Page 81: Decomposing Applications for Scalability and Deployability (April 2012)

Services available on Cloud Foundry

81

Page 82: Decomposing Applications for Scalability and Deployability (April 2012)

Creating a service instance$ vmc create-service mysql --name mysql1Creating Service: OK

$ vmc services......

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

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

Page 83: Decomposing Applications for Scalability and Deployability (April 2012)

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

83

Path to application

Required services

Page 84: Decomposing Applications for Scalability and Deployability (April 2012)

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

84

Path to application

Required services

Page 85: Decomposing Applications for Scalability and Deployability (April 2012)

One command to create services and deploy application$ vmc push Would you like to deploy from the current directory? [Yn]: Pushing application 'inventory'...Creating Application: OKCreating Service [si-rabbit]: OKBinding Service [si-rabbit]: OKCreating Service [si-mongo]: OKBinding Service [si-mongo]: OKCreating Service [si-redis]: OKBinding Service [si-redis]: OKUploading Application: Checking for available resources: OK Processing resources: OK Packing application: OK Uploading (12K): OK Push Status: OKStaging Application 'inventory': OK Starting Application 'inventory': OK Pushing application 'store'...Creating Application: OKBinding Service [si-mongo]: OKBinding Service [si-rabbit]: OKUploading Application: Checking for available resources: OK Processing resources: OK Packing application: OK Uploading (5K): OK Push Status: OKStaging Application 'store': OK Starting Application 'store': ... 85

vmc push:•Reads the manifest file•Creates the required services•Deploys all the applications

Page 86: Decomposing Applications for Scalability and Deployability (April 2012)

Application configuration via environment variables

String value = System.getenv("PAYMENT_SVC")

@Value("#{systemEnvironment['PAYMENT_SVC']}")private String envVariable;

$ vmc env-add cf1 PAYMENT_SVC=http://...Adding Environment Variable

[PAYMENT_SVC=http://...]: OKStopping Application: OKStaging Application: OK

Page 87: Decomposing Applications for Scalability and Deployability (April 2012)

Micro Cloud Foundry: new developer sandbox

87

Open source Platform as a Service project

App Instances Services

10.04

A PaaS packaged as a VMware Virtual Machine

Use as a developer sandbox

• Use the services from Junit integration tests

• Deploy your application for functional testing

• Remote debugging from STS

Page 88: Decomposing Applications for Scalability and Deployability (April 2012)

Using Caldecott…$ vmc tunnel1: mysql-135e02: mysql1Which service to tunnel to?: 2Password: ********Stopping Application: OKRedeploying tunnel application 'caldecott'.Uploading Application: Checking for available resources: OK Packing application: OK Uploading (1K): OK Push Status: OKBinding Service [mysql1]: OKStaging 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: none2: mysqlWhich client would you like to start?: 2

Page 89: Decomposing Applications for Scalability and Deployability (April 2012)

…Using CaldecottLaunching '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 10944342Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.

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

mysql>

Page 90: Decomposing Applications for Scalability and Deployability (April 2012)

Running JUnit test with Caldecott

90

Configure your test code to use port + connection info

Page 91: Decomposing Applications for Scalability and Deployability (April 2012)

Summary§ Monolithic applications are simple to develop and deploy

BUT applying the scale cube

§ Decomposes your application into services§ Enables scaling for transactions and data volumes§ Tackles application complexity§ Enables scaling for development§ Enables frequent, independent deployments§ Make it easy to leverage other technologies

AND

§ Cloud Foundry simplifies the development and deployment of “service-oriented” applications

91

Page 92: Decomposing Applications for Scalability and Deployability (April 2012)

Questions?

@crichardson [email protected]

www.cloudfoundry.com promo code CFOpenTour2012