cloud foundry @ rubyconf china 2001

32
© 2011 VMware Inc. All rights reserved ` the industry's first open platform as a service

Upload: haofei-wang

Post on 06-May-2015

3.048 views

Category:

Technology


0 download

TRANSCRIPT

© 2011 VMware Inc. All rights reserved

`

the industry's first open platform as a service

introduction

2 RubyConf China 2011

who am I

Haofei Wang

Twitter @haofei

Weibo @haofei

Email [email protected]

3 RubyConf China 2011

what is cloud foundry

4

radically simplify the development and

operation of applications and services

across public and private clouds.

completely written in pure ruby.

RubyConf China 2011

ruby creator “Matz"

matsumoto joins heroku as

chief architect

5 RubyConf China 2011

cloud foundry ecosystem

6

private

clouds

public

clouds

micro

clouds

.js

data

services

other

services

msg

services

framework and runtime interface

RubyConf China 2011

two key initiatives

• cloudfoundry.org

• OSS project, Apache License, Version 2.0

• github.com/cloudfoundry

• cloudfoundry.com

• the live service

• operated by VMware, powered by VMware vSphere

7 RubyConf China 2011

applications

8 RubyConf China 2011

at a high level: app evolution

• evolution step1: start with a great idea for an app

• build web app as a prototype, major refactor it into v1

• written using spring, rails, or sinatra with scripting around the edges

• scale, learn by doing, experiment with new approaches, etc.

• evolution step2: at scale, tons of traffic, pushing limits

• need to extend 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 cloudfoundry scalability and self healing

9 RubyConf China 2011

at a high level: my expectations

• expectation1: write code not tickets…

• the application is my unit of currency

• expect friction free deployment, the system is 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 nginx configs is not fun

• expectation2: choose my own cloud

• develop and test on a low cost cloud

• deploy into a high SLA cloud

• don’t want to learn a new model each time I go to a new cloud

10 RubyConf China 2011

typical app

• spring web app, rails, sinatra, node.js, etc.

• elastic pool of app instances, easy to scale

• database accessible by all instances

• most apps start out looking something like this

11

elastic pool

database app

instance

app

instance

system load balancer

RubyConf China 2011

deploying typical app the old way

12

mvc web app

[mysqld] user = foobar port = 3306 basedir = /usr bind-address = 172.58.77.101 key_buffer = 16M thread_stack = 128K thread_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 - ruby files: - core/app/fe/**/* - core/common/**/*

[blah] - blah blah blah

RubyConf China 2011

deploying typical app on cloudfoundry

13

# to create and boot the app for the first time vmc target http://api.cloudfoundry.com vmc push myapp –instances 2 –mem 64M –path ../code vmc create-service mysql –name mydb –bind myapp # update live app with new code vmc update myapp –path ../code

mvc web app

RubyConf China 2011

quick summary

• cloudfoundry lets me start small

• learn new approaches, frameworks, and services

• develop on my cloud or yours

• cloudfoundry lets me grow my app

• multi node distributed systems

• built in scaling at the node level

• cloudfoundry lets me deploy/run with no friction

• there is no learning curve. 0 to cloud in 3 commands

• cloudfoundry is my architect, F$#@ IT!

• cloudfoundry lets me choose my own cloud

14 RubyConf China 2011

logical architecture

15 RubyConf China 2011

applications, instances, services, tools

16

application tools

application concepts

instances make my app scale. the more

instances, the more load the app can handle

my code

all of the code, libraries, and data that are

needed to run on a system supplied stack

apps are url addressable, can have multiple

urls, allow custom domains on some clouds http://www.foo

services are used to extend an app with

higher level functions kv store, email, etc.

the command line tool: vmc, and sts plugin

are the primary tools used by developers

$ vmc update myapp $ vmc apps $ vm

RubyConf China 2011

cloudfoundry logical view

• infrastructure abstraction: servers, networks, storage delivered as software

• no more wires, boxes, configuring, cooling

• cloudfoundry abstraction

• applications, instances, and services

• manage to the boundaries of your code

• cloudfoundry is your architect

17

cloudfoundry

infrastructure

client tools user apps user apps

RubyConf China 2011

api surface area

• core app lifecycle api

• create, start, stop, update

• set url(s), instance count, memory

• get stats, logs, crashes, files

18

• the services api

• enumerate system serves

• select and create service instance

• bind/unbind service & apps

• miscellaneous

• REST api with JSON payloads, full function api

• info about for both system and account space

• account management api

• vmc command line app excercises the entire api

RubyConf China 2011

vmc command line tooling

Create app, update app, control app vmc 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 information vmc 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 information vmc 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-user vmc services, vmc apps, vmc info

19 RubyConf China 2011

system architecture

20 RubyConf China 2011

architectural principles

• dynamic discovery and binding

• no persistent configuration of components

• all components discover their surroundings automatically via messaging

• no prescribed boot order

• self healing

• applications and system components auto start and auto config on failure

• flap detection and prevention built in

• horizontal scaling

• each core component can run as 1-N instances

• components are peers, no explicit sharding

21 RubyConf China 2011

cloud foundry kernel (OSS)

22

app

execution

(deas)

redis

database

app lifecycle

management

router

blobstore

service

lifecycle

management

apps

service

instances

auth/

authz

nats

RubyConf China 2011

app lifecycle management

23

cc

database

cloud

controller

NFS

health

manager

fetch droplets

start/stop instances

get expected

state

actual

state

resources,

droplets, packages

• cloud controller manages all aspects of lifecycle

• CRUD operations for apps

• staging apps (gathering all 3rd party components, creating start scripts, rewriting app environment etc)

• fetching, building and caching gems

• serving droplets to DEAs

• securing and scaling the cloud controller is challenging (and dangerous)

dea

RubyConf China 2011

router

24

nginx

router.rb

nats

dea

router

<app>.cf.com -> node:port

proxied

request

http request

• all data flows from nginx to the router.rb

• built on eventmachine – EM has no flow control

• bloats the ruby vm

• 2x the number of syscalls

• latency on every io

• sticky session support

RubyConf China 2011

app execution

25

apps

start/stop

instances

fetch droplets

direct

communication

with services

• apps run in separate processes protected with unix security

• all see the same resources: ports, file system, etc

• can talk to entire service network by design

• apps can launch attacks against other deas, services and the cloud controller

• rooting a dea compromises the entire dea, including the nats message bus

dea.rb

RubyConf China 2011

service provider

26

NATS cloud controller

service gateway vm container

service node

service instance

service instance

cloud foundry

services API gateway/node

private protocol

service components

RubyConf China 2011

at scale: multi-node, distributed system

27 RubyConf China 2011

auto scaling producer/consumer

28

autoscaler

front end

producer

front end

producer

back end

consumer

back end

consumer

back end

consumer

mongodb redis rabbitMQ

RubyConf China 2011

deploying app on cloudfoundry

29

# create the front end and backend apps # front end is small but multi-instance vmc push fe –instances 8 –mem 64M –path ../fe_code vmc push be –instances 2 –mem 256M –path ../be_code # create the services and bind per spec vmc create-service mongodb –name mongo –bind fe vmc create-service redis –name redis –bind fe vmc bind-service redis be # to perform a rolling update of new code vmc update fe –path ../fe_code vmc update be –path ../be_code

multi-node app

RubyConf China 2011

hacking cloud foundry

bash < <(curl -s -k –B https://raw.github.com/cloudfoundry/v

cap/master/setup/install)

30 RubyConf China 2011

we’re hiring in china

• SRE – Platform/Delivery Engineer, JD: p001

• Core Engineer, JD: k001, k001-ncg

• Delivery Engineer, JD: dm001, dm002

• QA Engineer, JD: qa001

• Project Manager, JD: pgm001

31 RubyConf China 2011