Cloud Foundry a Developer's Perspective

24
Cloud Foundry – A Developer’s Perspective April 13 th 2011 Cloud Foundry From A Developer’s Perspective Multi-Language, Multi-Framework PaaS 1

description

Presentation on Cloud Foundry a Developer's Perspective given by Derek Collison and the Cloud Foundry Team

Transcript of Cloud Foundry a Developer's Perspective

Page 1: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

Cloud FoundryFrom A Developer’s Perspective

Multi-Language, Multi-Framework PaaS

1

Page 2: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

2

DEALING WITH APPLICATIONSFrom a Developer’s Perspective

Page 3: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

3

Application Evolution• Start with a great idea for an app

– Build a typical web app as a prototype, major refactor it into v1– Written using Spring, Rails, or Sinatra with scripting around the

edges– Allow me to scale, learn by doing, experiment with new

approaches, etc.

• At scale, tons of traffic, pushing some limits– Extend my app with a backend processing tier– Use some services that are shared between my front end and

backend components e.g., messaging, KV store, etc.– Use some services that are private to each tier e.g., KV store,

document store, SQL database etc.– Leverage Cloud Foundry scalability and self healing

Page 4: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

4

Developer Expectations• Write code not tickets…

– The application is my unit of currency– Expect friction free deployment, i.e., the system acts as the architect– I manage to the boundaries of my code, no further– Don’t force me to learn how to cobble together a middleware stack,

and then service it for life– I write code because its fun: configuring a kernel, installing packages,

writing configs is not fun

• Choose my own cloud– Develop and test on a low cost cloud– Deploy into a high SLA cloud– Deploy into clouds where my app is needed– Don’t want to learn a new model each time I go to a new cloud

Page 5: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

5

Typical Web Application• Spring web app, Rails, Sinatra, Node.js, etc.– Elastic pool of app instances, easy to scale– Database accessible by all instances

elastic pool

databaseapp instanceapp instance

system load balancer

Page 6: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

6

Deploying Web App the Old Way

mvc web app

[mysqld]user = foobarport = 3306basedir = /usrbind-address = 172.58.77.101key_buffer = 16Mthread_stack = 128Kthread_cache_size = 8…

[nginx]http.include mime.types;default_type: application/octet-stream;log_format: main ‘$remote_addr - $remote_user []…’keepalive_timeout 65;

[tomcat]<Connector redirectPort=“8443” emptySessionPath…/><bean id=“sessionFactory” class=“org.springframework…/> [frontend]dependencies:- mysqlclient- rubyfiles:- core/app/fe/**/*- core/common/**/*

[blah]- blah blah blah

Page 7: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

7

Deploying Web App on Cloud Foundry

mvc web app

# to target and login to cloud foundryvmc target http://api.cloudfoundry.comvmc login

# to create and boot the app for the first timevmc push myapp –instances 2 –mem 64M –path ../code

# to create the database and bind it to the appvmc create-service mysql –name mydb –bind myapp

# update live app with new codevmc update myapp –path ../code

Page 8: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

8

At Scale – Multi-Node Distributed App

rabbitMQ

redis mysql

system load balancer

elastic pool

front_end front_end

elastic pool

back_endmongodb

Page 9: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

9

Complex App on Cloud Foundry

# create the front end and backend apps# front end is small but multi-instancevmc push fe –instances 8 –mem 64M –path ../fe_codevmc push be –instances 2 –mem 256M –path ../be_code

# create the services and bind per specvmc create-service mysql –name mysql –bind fevmc create-service mongodb –name mongo –bind bevmc create-service rabbit –name rabbit –bind fevmc create-service redis –name redis –bind fevmc bind-service redis bevmc bind-service rabbit be

# to perform an update of codevmc update fe –path ../new_fe_codevmc update be –path ../new_be_code

multi-node, distributed app

Page 10: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

10

Summary• Cloud Foundry lets me start small– Learn new approaches, frameworks, and services– Develop on my cloud or yours

• Cloud Foundry lets me grow my app– Multi node distributed systems– Built-in scaling at the node level

• Cloud Foundry lets me deploy & run with no friction– There is no learning curve. 0 to cloud in 3 clicks– Cloud Foundry is my infrastructure architect

• Cloud Foundry lets me choose my own cloud

Page 11: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

11

DEVELOPER VISIBLE ARCHITECTUREFrom a Developer’s Perspective

Page 12: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

12

Applications, Instances, Services, ToolsApplication Concepts

Instances make my application scale. The more instances the more load the app can handle

my code

All of the code, libraries, and, data that are needed in order to run my code on a system supplied stack

My app is URL addressable and can have multiple URLs, some clouds allow custom domainshttp://

www.foo

Services are used to extend an application with higher level functions like a KV store or email gateway

Application Tools

vmc (command line tool) and STS plugin (IDE) are the primary tools used by developers

$ vmc update myapp$ vmc apps$ vm

Page 13: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

13

Logical View of Cloud Foundry• Infrastructure Abstraction (Cloud Foundry hides this)

– Servers, networks, storage delivered as software– No more wires, boxes, configuring, cooling

• Cloud Foundry Abstraction– Applications, instances, and services– Manage to the boundaries of your code– Cloud Foundry is your architect

infrastructure

Cloud Foundry

user apps user appsclient tools

Page 14: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

14

Cloud Foundry APIsApplication Lifecycle API• Create, start, stop, update• Set URL(s), instance count,

memory• Get stats, logs, crashes, files

Services API• Enumerate system services• Select and create service instance• Bind and unbind service & app(s)

Cloud Foundry

APIsAlso includes• Info API for both system and account space• Account management API, All APIs are RESTful with

JSON payloads. The vmc CLI app exercises the entire API. The STS plugin provides similar functionality within the STS IDE

Page 15: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

15

The vmc CLICreate app, update app, control appvmc push [appname] [--path] [--url] [--instances N] [--mem] [--no-start]vmc update <appname> [--path PATH]vmc stop <appname>vmc start <appname>vmc target [url]

Update app settings, get app informationvmc mem <appname> [memsize]vmc map <appname> <url>vmc instances <appname> <num | delta>vmc {crashes, crashlogs, logs} <appname>vmc files <appname> [path]

Deal with services, users, and informationvmc create-service <service> [--name servicename] [--bind appname]vmc bind-service <servicename> <appname>vmc unbind-service <servicename> <appname>vmc delete-service <servicename>

vmc user, vmc passwd, vmc login, vmc logout, vmc add-uservmc services, vmc apps, vmc info

Page 16: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

16

WHAT’S UNDER THE HOODFrom a Developer’s Perspective

Page 17: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

Cloud Foundry Internal View

17

Page 18: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

18

Cloud Foundry Logical View

Router

Infrastructure

Health Manager

DEA: execution environmentServices: core, ecosystem, etc.

user appsCloud Controller user apps

vmc client STS plugin browser(user app access)

Page 19: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

19

Cloud Foundry: Router• The router receives all traffic from the outside world and

maintains the mapping from external URL to internal application instance

• The router performs this job for all Cloud Foundry API entry points (typically from vmc or STS) as well as for all application specific traffic

• The router acts as a load balancer, distributing requests evenly across all instances of a given app

Page 20: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

20

Cloud Foundry: Cloud Controller• It is responsible for all state changes in the system– Ensuring all dependencies are available– Binding the application to services

• Anything that effects users, apps, or services is controlled by the Cloud Controllers– Examples : vmc push, vmc instances, vmc create-service,

etc. are driven by the Cloud Controller• Once staged, the Cloud Controller is responsible for

connecting the application to a DEA execution unit

Page 21: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

21

Cloud Foundry: Health Manager• The Health Manager works closely with the Cloud Controller

and DEAs to ensure that applications stay alive and healthy• When an app instance crashes, it is the Health Manager that

notes this and arranges for a replacement instance• If the Health Manager detects rapid and repeated crashes, it

declares the app to be in a “flapping” state and does not try to revive the app instances that are sick

Page 22: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

22

Cloud Foundry: DEA• The system maintains a pool of standby DEAs and these act as

the VM-level container for an application• DEAs support both single and multi-tenant operation (1 app

per DEA VM, or n apps per DEA VM)• DEAs provide a secure/constrained OS environment running

the application’s app-server and the application code

Page 23: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

23

Cloud Foundry: Services• Services are one of the extensibility planes in Cloud Foundry• MySQL, Redis, MongoDB, RabbitMQ, etc. are all examples of

services• Services may be shared across applications• Cloud Foundry abstracts the provisioning aspect of services

through a uniform API hosted in the cloud controller• The net is that its very easy to take an app and add a service to

the app in a uniform way

Page 24: Cloud Foundry a Developer's Perspective

Cloud Foundry – A Developer’s PerspectiveApril 13th 2011

24

Questions