migrating to cloudfoundry

56
© 2012 VMware, Inc. All rights reserved. Migrating to Cloud Foundry Peter Ledbrook - VMware t: @pledbrook e: [email protected]

Upload: gr8conf

Post on 17-May-2015

2.907 views

Category:

Technology


0 download

DESCRIPTION

As presentet at GR8Conf EU 2012: http://gr8conf.eu/Presentations/Migrating-to-CloudFoundry

TRANSCRIPT

Page 1: Migrating to CloudFoundry

© 2012 VMware, Inc. All rights reserved.

Migrating to Cloud Foundry

Peter Ledbrook - VMwaret: @pledbrooke: [email protected]

Page 2: Migrating to CloudFoundry

What’s happening with applications today?

2

Frameworks are what really matter • Developer productivity and innovation

• Reduce time to market

New application types • Mobile, Social, SaaS

•  Apps released early and often

Data intensive •  Emerging requirements: elasticity, multi-cloud

• Web orientation drives exponential data volumes

Deployed on virtual and cloud infrastructures •  Virtualization, Cloud, PaaS

Page 3: Migrating to CloudFoundry

The promise of PaaS

3

InfrastructureCPU Memory OS

PlatformServlet Container Database Other services

App 1 App 2 App 3

• Zero config• Automatic provisioning

Page 4: Migrating to CloudFoundry

Deploy and scale applications in seconds, without locking yourself

into a single cloud

Simple, Open,

Flexible, Scalable

The Open Platform as a Service

Page 5: Migrating to CloudFoundry

5

Choice of frameworks, services & cloudsOSS community

+ Standalone!

Page 6: Migrating to CloudFoundry

6

Choice of frameworks, services & cloudsOSS community

Applica'on*Service*Interface*

Data Services

Other Services

Msg Services

vFabric Postgres

vFabric RabbitMQTM

Additional partners services …

+ Standalone!

Page 7: Migrating to CloudFoundry

7

Choice of frameworks, services & cloudsOSS community

Applica'on*Service*Interface*

Data Services

Other Services

Msg Services

vFabric Postgres

vFabric RabbitMQTM

Additional partners services …

Private((Clouds((

Public(Clouds(

Micro(Clouds(

.COM

Partners(

Cloud(Provide

r(Interface(

Avoid

Lock-in

+ Standalone!

Page 8: Migrating to CloudFoundry

Real choice of provider

8

Choice of Cloud Infrastructure

Bare metal

Choice of Private Cloud Distributions

Choice of Public Cloud Providers

.COM

Page 9: Migrating to CloudFoundry

Deployment tools

9

vmc (command line)

Page 10: Migrating to CloudFoundry

Core services

10

Page 11: Migrating to CloudFoundry

Developer Perspective

• Program to standard APIs– SQL drivers– Mongo client libraries– ...

• Connection settings from VCAP_SERVICES environment variable

11

Page 12: Migrating to CloudFoundry

When you’re ready to deploy...

12

!!!$!vmc!target!<any!cloud>!

!!!$!vmc!push!<my6app>!

!!!!>!bind!services?!Yes!

!!$!vmc!instances!<my6app>!+100!!

!!! That’s all folks!

Page 13: Migrating to CloudFoundry

The sample application

• http://grails.org• Built with Grails

– JVM web framework– Spring MVC under the hood– Groovy as the main development language

13

Page 14: Migrating to CloudFoundry

14

Page 15: Migrating to CloudFoundry

15

Page 16: Migrating to CloudFoundry

16

Page 17: Migrating to CloudFoundry

17

Page 18: Migrating to CloudFoundry

Architecture

18

Controller View

HTTP

Service

GORM/Hibernate

Database

REST

Async Plugin Update

Twitter

Forum+ Jobs

Page 19: Migrating to CloudFoundry

App Node

Cache

SearchindicesJob

Single instance

19

App Node

Cache

SearchindicesJob

App Node

Cache

SearchindicesJob

Local, embedded ehcache

Page 20: Migrating to CloudFoundry

App Node

Cache

SearchindicesJob

Single instance

20

App Node

Cache

SearchindicesJob

App Node

Cache

SearchindicesJob

Local Lucene indexes

Page 21: Migrating to CloudFoundry

App Node

Cache

SearchindicesJob

Single instance

21

App Node

Cache

SearchindicesJob

App Node

Cache

SearchindicesJob

Single job of each type

Page 22: Migrating to CloudFoundry

App Node

Cache

SearchindicesJob

Multi-instance

22

App Node

Cache

SearchindicesJob

App Node

Cache

SearchindicesJob

1. Update2. Returnlatest

3. Returnstale data

3. Returnstale data

Page 23: Migrating to CloudFoundry

App Node

Cache

SearchindicesJob

Multi-instance

23

App Node

Cache

SearchindicesJob

App Node

Cache

SearchindicesJob

Mail Job Mail Job Mail Job

Jobs are executed three times?

Page 24: Migrating to CloudFoundry

Caching

24

Caching shared data==

Shared cache

Page 25: Migrating to CloudFoundry

Ehcache

25

Simple & effectiveDistributed modeBut...

No multicast on Cloud Foundry!

Page 26: Migrating to CloudFoundry

So, what do we use?

• Key-value store• In-memory with persistence (fast)• Pub-sub• Single service for all app instances

26

Page 27: Migrating to CloudFoundry

Grails Cache plugin

• Based on Spring 3.1 cache abstraction– @Cacheable– @CacheEvict

• Ehcache & Redis providers– Spring Data RedisCacheManager

• <cache:block>• <cache:render template=”...”>

27

Page 28: Migrating to CloudFoundry

28

Page 29: Migrating to CloudFoundry

HTTP session

29

Sticky sessions!

Page 30: Migrating to CloudFoundry

HTTP session

30

Or consider Redis fordistributed session store

Page 31: Migrating to CloudFoundry

Jobs

• @Scheduled, Quartz, etc.• Which node runs a job?

31

Local data

Do nothing

Shared data

Quartz JDBC Store

Worker

Page 32: Migrating to CloudFoundry

AppNode

Distribution with workers

32

AppNode

AppNode

WorkerWorkerWorker

?

Page 33: Migrating to CloudFoundry

AppNode

Distribution with workers

33

AppNode

AppNode

WorkerWorkerWorker

Node-specificdata

Page 34: Migrating to CloudFoundry

Jobs

34

Pros Cons

Quartz

Workers

Efficient in-JVM processingTried & testedRelatively simple

Extra burden on web server

Use right language for the jobDistribute the workload

Counts against your quota

Page 35: Migrating to CloudFoundry

Search

• Compass 2.0– Lucene indexes on local file system– Indexes database data

• > 1 node == stale indexes• Search as a service

– Solr– Elastic Search– Index Tank– Amazon Cloud Search– Not on Cloud Foundry (yet)

• Synchronise indexes across nodes!– Eventual consistency is good enough

35

Page 36: Migrating to CloudFoundry

Event bus

Synchronisation with an event bus

36

Event bus

Event bus

Initiate event

Distribute

Distribute

Distribute

Page 37: Migrating to CloudFoundry

Event bus

37

Event Bus

Plugins ApplicationPluginsPlugins

Spring Integration AMQP

Save entity IndexUpdate

read DBsCall REST

service

Page 38: Migrating to CloudFoundry

Event bus

• Platform Core plugin– Event API + simple in-memory implementation

• Events Si plugin– Event bus implementation using Spring Integration

• Events Push plugin– Bridge events to browser via Atmosphere

• Potentially the standard cloud architecture– Message passing (relatively) easy to scale horizontally

38

Page 39: Migrating to CloudFoundry

Schrödinger’s Cat

39

Is the cat alive or dead?

Page 40: Migrating to CloudFoundry

Schrödinger’s Cat

40

Resolved only when we look

Page 41: Migrating to CloudFoundry

Local filesystem

41

There’s a file in here!

Does the file exist or not?

Page 42: Migrating to CloudFoundry

Ephemeral file system

• VMs are created and destroyed– => application file system created and destroyed– You can write to the local file system...– ...but you will probably lose that data at some point

• Don’t store persistent data on local FS!– File uploads

42

Page 43: Migrating to CloudFoundry

Wiki images

43

Controller

User

Upload

GridFSBlob store

mongo-file plugin for example

Page 44: Migrating to CloudFoundry

Logging

• View logs with `vmc logs`• What if the application instance is restarted?

– Logs are gone• What about multiple application instances?

– `vmc logs --instance 1` or `vmc logs --all`– but 30 days after deployment?

44

Page 45: Migrating to CloudFoundry

App Node

Distributed logging

45

App Node

App Node

AMQPAppender

AMQPAppender

AMQPAppender

Node.js +SockJS +MongoDB

Page 46: Migrating to CloudFoundry

Config

46

Package in the app?

Store in database?

Inject via environment variable?

Page 47: Migrating to CloudFoundry

Dynamic config load

47

Config.groovy

ConfigLoader.groovy

Page 48: Migrating to CloudFoundry

Mail

• No SMTP - oh no!• HTTP providers

– SendGrid– Mailgun– Amazon Simple Email Service

48

Page 49: Migrating to CloudFoundry

Easy HTTP Mail

49

resources.groovy

MailerJob.groovy

Page 50: Migrating to CloudFoundry

Data

50

How do we load initial data?

Perform data migrations?

Back data up?

Page 51: Migrating to CloudFoundry

Access your services

51

Mongo Client

vmc tunnel

Cloud Foundry

MongoDBservice

(SSH Tunnel)

Page 52: Migrating to CloudFoundry

Import/export

52

Import == mysql < data.sql

Export == mysqldump

Page 53: Migrating to CloudFoundry

Application (WIP*)

53

https://github.com/grails-samples/grails-website

http://grails-website.cloudfoundry.com/

Source

Live

* Work in Progress

Page 54: Migrating to CloudFoundry

Summary

• PaaS is the application platform for the Cloud era• Cloud Foundry can support real applications• PaaS will change the way you write apps

– Design for horizontal scalability– Account for ephemeral file system– Rich set of services– Go polyglot!

• Tools & libraries are important– Spring for the win!

• Can use Redis in place of RabbitMQ for some patterns

54

Page 55: Migrating to CloudFoundry

What’s next?

• Sign up - www.cloudfoundry.com• Get the source code - www.cloudfoundry.org• Download your Micro Cloud Foundry –

my.cloudfoundry.com/micro• Learn more on the Cloud Foundry blog -

blog.cloudfoundry.com• Follow us - @cloudfoundry

55

Page 56: Migrating to CloudFoundry

Q&A