SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
developers perspective
               mark lucovsky
      vp of engineering, cloud foundry
agenda
•    cloud foundry – PaaS
•    sample app:
     •    polyglot in action
     •    node
     •    redis
     •    json
     •    ruby
     •    html5
     •    jQuery
     •    multi-tier
     •    horizontally scalable
     •    vmc manifest
     •    etc.

 2                          developer perspective v2.0
cloud foundry




3       developer perspective v2.0
cloud foundry: open paas
•    active open source project, liberal license
•    infrastructure neutral core, runs on any IaaS/Infra
•    extensible runtime/framework, services architecture
     •    node, ruby, java, scala, erlang, etc.
     •    postgres, neo4j, mongodb, redis, mysql, rabbitmq
•    clouds: raw infra structure, to fully managed (AppFog)
•    VMware’s delivery forms
     •    raw bits and deployment tools on GitHub
     •    Micro Cloud Foundry
     •    cloudfoundry.com



 4                         developer perspective v2.0
key abstractions
•    applications
•    instances
•    services
•    vmc – cli (based almost 1:1 on control api)




 5                       developer perspective v2.0
hello world: classic

    $	
  cat	
  hw.c	
  
    #include	
  <stdio.h>	
  
    main()	
  {	
  
    	
  	
  printf(“Hello	
  Worldn”);	
  
    }	
  




    $	
  cc	
  hw.c;	
  ./a.out	
  




6                                     developer perspective v2.0
hello world of the cloud

    $	
  cat	
  hw.rb	
  
    require	
  'rubygems'	
  
    require	
  'sinatra'	
  
    	
  
    $hits	
  =	
  0	
  
    get	
  '/'	
  do	
  
    	
  	
  $hits	
  =	
  $hits	
  +	
  1	
  
    	
  	
  "Hello	
  World	
  -­‐	
  #{$hits}"	
  
    end	
  




    $	
  vmc	
  push	
  hw	
  


7                                       developer perspective v2.0
cc	
  hw.c

    vmc	
  push	
  hw
8         developer perspective v2.1
hello world of the cloud: scale it up

    $	
  vmc	
  instances	
  hw	
  10	
  
    	
  
    get	
  '/'	
  do	
  
    	
  	
  $hits	
  =	
  $hits	
  +	
  1	
  
    	
  	
  "Hello	
  World	
  -­‐	
  #{$hits}"	
  
    end	
  
    	
  
    #	
  above	
  code	
  is	
  broken	
  for	
  >	
  1	
  instance	
  
    #	
  move	
  hit	
  counter	
  to	
  redis,	
  hi-­‐perf	
  K/V	
  store	
  
    $	
  vmc	
  create-­‐service	
  redis	
  –bind	
  hw	
  
    	
  
    get	
  '/'	
  do	
  
    	
  	
  $hits	
  =	
  $redis.incr(‘hits’)	
  
    	
  	
  "Hello	
  World	
  -­‐	
  #{$hits}"	
  
    end	
  
9                                     developer perspective v2.0
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	
  




10                                                 developer perspective v2.0
sample app




11     developer perspective v2.0
12   developer perspective v2.0
stac2: load generation system
- jQuery, jQuery UI             json-p            stac2             - 2 x 128mb
- haml templates                                frontend            - ruby 1.8.7, sinatra
- 100% JS based UI
                           smtp       http                       json
                       email                                        - 16 x 128mb*
                                               api server           - node.JS, 0.6.8
                      reports

                                   rpush                         redis api

                                                   redis

                                  blpop         redis api         blpop
        - 96 x 128mb                                                         - 16 x 128mb*
        - ruby 1.8.7, sinatra   vmc worker                    http worker    - node.JS, 0.6.8
                                                              * - api server and http worker
                                                              share the same node.JS
                                                              process/instance
 13                              developer perspective v2.0
deployment instructions




      $ cd ~/stac2
      $ vmc push

14            developer perspective v2.0
how is this possible?
$	
  cd	
  ~/stac2;	
  cat	
  manifest.yml	
  
applications:	
  
	
  	
  ./nabh:	
  
	
  	
  	
  	
  instances:	
  16	
  
	
  	
  	
  	
  mem:	
  128M	
  
	
  	
  	
  	
  runtime:	
  node06	
  
	
  	
  	
  	
  url:	
  ${name}.${target-­‐base}	
  
	
  	
  	
  	
  services:	
  
	
  	
  	
  	
  	
  	
  nab-­‐redis:	
  
	
  	
  	
  	
  	
  	
  	
  	
  type:	
  :redis	
  
./nabv:	
  
	
  	
  	
  	
  instances:	
  96	
  
	
  	
  	
  	
  mem:	
  128M 	
  	
  
	
  	
  	
  	
  runtime:	
  ruby18	
  
	
  	
  	
  	
  url:	
  ${name}.${target-­‐base}	
  
	
  	
  	
  	
  services:	
  
	
  	
  	
  	
  	
  	
  nab-­‐redis:	
  
	
  	
  	
  	
  	
  	
  	
  	
  type:	
  :redis	
  
./stac2:	
  
	
  	
  	
  	
  instances:	
  2	
  
	
  	
  	
  	
  mem:	
  128M 	
  	
  
	
  	
  	
  	
  runtime:	
  ruby18	
  
	
  	
  	
  	
  url:	
  ${name}.${target-­‐base}	
  


15                                          developer perspective v2.0
design tidbits
•    producer/consumer pattern using rpush/blpop
•    node.JS: multi-server and high performance async i/o
•    caldecott – aka vmc tunnel for debugging
•    redis sorted sets for stats collection
•    redis expiring keys for rate calculation




16                        developer perspective v2.0
producer/consumer
•    core design pattern
•    found at the heart of many complex apps
classic mode:
- thread pools
- semaphore/mutex, completion ports, etc.
- scalability limited to visibility of the work queue



 producer         work     work queue              work       consumer



cloud foundry mode:
- instance pools
- redis rpush/blpop, rabbit queues, etc.
- full horizontal scalability, cloud scale

17                               developer perspective v2.0
producer/consumer: code
//	
  producer	
  
function	
  commit_item(queue,	
  item)	
  {	
  
	
  	
  //	
  push	
  the	
  work	
  item	
  onto	
  the	
  proper	
  queue	
  	
  
	
  	
  redis.rpush(queue,	
  item,	
  function(err,	
  data)	
  {	
  
	
  
	
  	
  	
  	
  //	
  optionally	
  trim	
  the	
  queue,	
  throwing	
  away	
  
	
  	
  	
  	
  //	
  data	
  as	
  needed	
  to	
  ensure	
  the	
  queue	
  does	
  
	
  	
  	
  	
  //	
  not	
  grow	
  unbounded	
  
	
  	
  	
  	
  if	
  (!err	
  &&	
  data	
  >	
  queueTrim)	
  {	
  
	
  	
  	
  	
  	
  	
  redis.ltrim(queue,	
  0,	
  queueTrim-­‐1);	
  
	
  	
  	
  	
  }	
  	
  	
  	
  
	
  	
  });	
  
}	
  
	
  

//	
  consumer	
  
function	
  worker()	
  {	
  
	
  	
  //	
  blocking	
  wait	
  for	
  workitems	
  
	
  	
  blpop_redis.blpop(queue,	
  0,	
  function(err,	
  data)	
  {	
  
	
  	
  	
  	
  	
  
	
  	
  	
  	
  //	
  data[0]	
  ==	
  queue,	
  data[1]	
  ==	
  item	
  
	
  	
  	
  	
  if	
  (!err)	
  {	
  
	
  	
  	
  	
  	
  	
  doWork(data[1]);	
  
	
  	
  	
  	
  }	
  
	
  	
  	
  	
  process.nextTick(worker);	
  	
  	
  	
  
	
  	
  });	
  
}	
  
	
  
  18                                               developer perspective v2.0
node.JS multi-server: http API server
//	
  the	
  api	
  server	
  handles	
  two	
  key	
  load	
  generation	
  apis	
  
//	
  /http	
  –	
  for	
  http	
  load,	
  /vmc	
  for	
  Cloud	
  Foundry	
  API	
  load	
  
var	
  routes	
  =	
  {“/http”:	
  httpCmd,	
  “/vmc”:	
  vmcCmd}	
  
	
  
//	
  http	
  api	
  server	
  booted	
  by	
  app.js,	
  passing	
  redis	
  client	
  
//	
  and	
  Cloud	
  Foundry	
  instance	
  	
  
function	
  boot(redis_client,	
  cfinstance)	
  {	
  
	
  	
  var	
  redis	
  =	
  redis_client;	
  
	
  	
  	
  
	
  	
  function	
  onRequest(request,	
  response)	
  {	
  
	
  	
  	
  	
  var	
  u	
  =	
  url.parse(request.url);	
  
	
  	
  	
  	
  var	
  path	
  =	
  u.pathname;	
  
	
  	
  	
  	
  if	
  (routes[path]	
  &&	
  typeof	
  routes[path]	
  ==	
  ‘function’)	
  {	
  
	
  	
  	
  	
  	
  	
  routes[path](request,	
  response);	
  
	
  	
  	
  	
  }	
  else	
  {	
  
	
  	
  	
  	
  	
  	
  response.writeHead(404,	
  {‘Content-­‐Type’:	
  ‘text/plain’});	
  
	
  	
  	
  	
  	
  	
  response.write(‘404	
  Not	
  Found’);	
  
	
  	
  	
  	
  	
  	
  response.end();	
  
	
  	
  	
  	
  }	
  
	
  	
  }	
  
	
  	
  server	
  =	
  http.createServer(onRequest).listen(cfinstance[‘port’]);                   	
  
}	
  



19                                      developer perspective v2.0
node.JS multi-server: blpop server
var	
  blpop_redis	
  =	
  null;	
  
var	
  status_redis	
  =	
  null;	
  
var	
  cfinstance	
  =	
  null;	
  
	
  
//	
  blpop	
  server	
  handles	
  work	
  requests	
  for	
  http	
  traffic	
  
//	
  that	
  are	
  placed	
  on	
  the	
  queue	
  by	
  the	
  http	
  API	
  server	
  
//	
  another	
  blpop	
  server	
  sits	
  in	
  the	
  ruby/sinatra	
  VMC	
  server	
  
function	
  boot(r1,	
  r2,	
  cfi)	
  {	
  
	
  	
  //	
  multiple	
  redis	
  clients	
  due	
  to	
  concurrency	
  constraints	
  
	
  	
  blpop_redis	
  =	
  r1;	
  
	
  	
  status_redis	
  =	
  r2;	
  
	
  	
  cfinstance	
  =	
  cfi;	
  
	
  	
  worker();	
  
}	
  
	
  
//	
  this	
  is	
  the	
  blpop	
  server	
  loop	
  
function	
  worker()	
  {	
  
	
  	
  blpop_redis.blpop(queue,	
  0,	
  function(err,	
  data)	
  {	
  
	
  	
  	
  	
  if	
  (!err)	
  {	
  
	
  	
  	
  	
  	
  	
  doWork(data[1]);	
  
	
  	
  	
  	
  }	
  
	
  	
  	
  	
  process.nextTick(worker);	
  	
  	
  	
  
	
  	
  });	
  
}	
  
	
  
20                                       developer perspective v2.0
caldecott: aka vmc tunnel
#	
  create	
  a	
  caldecott	
  tunnel	
  to	
  the	
  redis	
  server	
  
$	
  vmc	
  tunnel	
  nab-­‐redis	
  redis-­‐cli	
  
Binding	
  Service	
  [nab-­‐redis]:	
  OK	
  
…	
  
Launching	
  'redis-­‐cli	
  -­‐h	
  localhost	
  -­‐p	
  10000	
  -­‐a	
  ...’	
  
	
  	
  
	
  
#	
  enumerate	
  the	
  keys	
  used	
  by	
  stac2	
  
redis>	
  keys	
  vmc::staging::*	
  
1)	
  “vmc::staging::actions::time_50”	
  
2)	
  “vmc::staging::active_workers”	
  
…	
  
	
  
#	
  enumerate	
  actions	
  that	
  took	
  less	
  that	
  50ms	
  
redis>	
  zrange	
  vmc::staging::actions::time_50	
  0	
  -­‐1	
  withscores	
  
1)	
  “delete_app”	
  
2)	
  “1”	
  
3)	
  “login”	
  
4)	
  “58676”	
  
5)	
  “info”	
  
6)	
  “80390”	
  
	
  
#	
  see	
  how	
  many	
  work	
  items	
  we	
  dumped	
  due	
  to	
  concurrency	
  constraint	
  
redis>	
  get	
  vmc::staging::wastegate	
  
“7829”	
  
	
  
	
  
  21                                         developer perspective v2.0
redis sorted sets for stats collection
#	
  log	
  action	
  into	
  a	
  sorted	
  set,	
  net	
  result	
  is	
  set	
  contains	
  
#	
  actions	
  and	
  the	
  number	
  of	
  times	
  the	
  action	
  was	
  executed	
  
#	
  count	
  total	
  action	
  count,	
  and	
  also	
  per	
  elapsed	
  time	
  bucket	
  
def	
  logAction(action,	
  elapsedTimeBucket)	
  	
  
	
  	
  #	
  actionKey	
  is	
  the	
  set	
  for	
  all	
  counts	
  
	
  	
  #	
  etKey	
  is	
  the	
  set	
  for	
  a	
  particular	
  time	
  bucket	
  e.g.,	
  _1s,	
  _50ms	
  
	
  	
  actionKey	
  =	
  “vmc::#{@cloud}::actions::action_set”	
  
	
  	
  etKey	
  =	
  “vmc::#{@cloud}::actions::times#{elapsedTimeBucket}”	
  
	
  	
  @redis.zincrby	
  actionKey,	
  1,	
  action	
  
	
  	
  @redis.zincrby	
  etKey,	
  1,	
  action	
  
end	
  
	
  
#	
  enumerate	
  actions	
  and	
  their	
  associated	
  count	
  
redis>	
  zrange	
  vmc::staging::actions::action_set	
  0	
  -­‐1	
  withscores	
  
1)	
  “login”	
  
2)	
  “212092”	
  
3)	
  “info”	
  
4)	
  “212093”	
  
	
  
#	
  enumerate	
  actions	
  that	
  took	
  between	
  400ms	
  and	
  1s	
  
redis>	
  zrange	
  vmc::staging::actions::time_400_1s	
  0	
  -­‐1	
  withscores	
  
1)	
  “create-­‐app”	
  
2)	
  “14”	
  
3)	
  “bind-­‐service”	
  
4)	
  “75”	
  
	
  
22                                           developer perspective v2.0
redis incrby and expire for rate calcs
#	
  to	
  calculate	
  rates	
  (e.g.,	
  4,000	
  requests	
  per	
  second)	
  
#	
  we	
  use	
  plain	
  old	
  redis.incrby.	
  the	
  trick	
  is	
  that	
  the	
  	
  
#	
  key	
  contains	
  the	
  current	
  1sec	
  timestamp	
  as	
  it’s	
  suffix	
  value	
  
#	
  all	
  activity	
  that	
  happens	
  within	
  this	
  1s	
  period	
  accumulates	
  
#	
  in	
  that	
  key.	
  by	
  setting	
  an	
  expire	
  on	
  the	
  key,	
  the	
  key	
  is	
  	
  
#	
  automatically	
  deleted	
  10s	
  after	
  last	
  write	
  
def	
  logActionRate(cloud)	
  
	
  	
  tv	
  =	
  Time.now.tv_sec	
  
	
  	
  one_s_key	
  =	
  "vmc::#{cloud}::rate_1s::#{tv}"	
  
	
  
	
  	
  #	
  increment	
  the	
  bucket	
  and	
  set	
  expires,	
  key	
  
	
  	
  #	
  will	
  eventually	
  expires	
  Ns	
  after	
  the	
  last	
  write	
  
	
  	
  @redis.incrby	
  one_s_key,	
  1	
  
	
  	
  @redis.expire	
  one_s_key,	
  10	
  
end	
  
	
  
#	
  return	
  current	
  rate	
  by	
  looking	
  at	
  the	
  bucket	
  for	
  the	
  previous	
  	
  
#	
  one	
  second	
  period.	
  by	
  looking	
  further	
  back	
  and	
  averaging,	
  we	
  	
  
#	
  can	
  smooth	
  the	
  rate	
  calc	
  
def	
  actionRate(cloud)	
  
	
  	
  tv	
  =	
  Time.now.tv_sec	
  -­‐	
  1	
  
	
  	
  one_s_key	
  =	
  "vmc::#{cloud}::rate_1s::#{tv}"	
  
	
  	
  @redis.get	
  one_s_key	
  
end	
  
	
  
23                                         developer perspective v2.0
24   developer perspective v2.0
www.cloudfoundry.com/jobs
25          developer perspective v2.0

Mais conteúdo relacionado

Mais procurados

Saint2012 mod process security
Saint2012 mod process securitySaint2012 mod process security
Saint2012 mod process securityRyosuke MATSUMOTO
 
PHPCR e API Platform: cosa significa davvero sviluppare un CMF con Symfony
PHPCR e API Platform: cosa significa davvero sviluppare un CMF con SymfonyPHPCR e API Platform: cosa significa davvero sviluppare un CMF con Symfony
PHPCR e API Platform: cosa significa davvero sviluppare un CMF con SymfonyInnoteam Srl
 
How to test code with mruby
How to test code with mrubyHow to test code with mruby
How to test code with mrubyHiroshi SHIBATA
 
Kubernetes #4 volume &amp; stateful set
Kubernetes #4   volume &amp; stateful setKubernetes #4   volume &amp; stateful set
Kubernetes #4 volume &amp; stateful setTerry Cho
 
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providersPLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providersPROIDEA
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudMassimiliano Dessì
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesHiroshi SHIBATA
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usStefan Adolf
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mrubyHiroshi SHIBATA
 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthroughSangwon Lee
 
Puppet and the HashiStack
Puppet and the HashiStackPuppet and the HashiStack
Puppet and the HashiStackBram Vogelaar
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
Integrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteBram Vogelaar
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Michele Orselli
 
Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMatt Aimonetti
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHiroshi SHIBATA
 

Mais procurados (20)

Saint2012 mod process security
Saint2012 mod process securitySaint2012 mod process security
Saint2012 mod process security
 
PHPCR e API Platform: cosa significa davvero sviluppare un CMF con Symfony
PHPCR e API Platform: cosa significa davvero sviluppare un CMF con SymfonyPHPCR e API Platform: cosa significa davvero sviluppare un CMF con Symfony
PHPCR e API Platform: cosa significa davvero sviluppare un CMF con Symfony
 
How to test code with mruby
How to test code with mrubyHow to test code with mruby
How to test code with mruby
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
Php version 5
Php version 5Php version 5
Php version 5
 
Kubernetes #4 volume &amp; stateful set
Kubernetes #4   volume &amp; stateful setKubernetes #4   volume &amp; stateful set
Kubernetes #4 volume &amp; stateful set
 
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providersPLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloud
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 Minutes
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthrough
 
Php on Windows
Php on WindowsPhp on Windows
Php on Windows
 
Puppet and the HashiStack
Puppet and the HashiStackPuppet and the HashiStack
Puppet and the HashiStack
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
Integrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suite
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich Kilmer
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby Core
 

Semelhante a Cloud Foundry Open Tour China (english)

Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发shaokun
 
Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?Adam Hodowany
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationBen Hall
 
qewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle Tierqewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle TierRob Tweed
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
ContainerDayVietnam2016: Docker for JS Developer
ContainerDayVietnam2016: Docker for JS DeveloperContainerDayVietnam2016: Docker for JS Developer
ContainerDayVietnam2016: Docker for JS DeveloperDocker-Hanoi
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetesLiran Cohen
 
DevOps and Hybrid Applications: What You Need to Know
DevOps and Hybrid Applications: What You Need to KnowDevOps and Hybrid Applications: What You Need to Know
DevOps and Hybrid Applications: What You Need to KnowDevOps.com
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefMatt Ray
 
Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...Laurent Domb
 
Apache OpenWhisk Serverless Computing
Apache OpenWhisk Serverless ComputingApache OpenWhisk Serverless Computing
Apache OpenWhisk Serverless ComputingUpkar Lidder
 
Supporting Hyper-V 3.0 on Apache CloudStack
Supporting Hyper-V 3.0 on Apache CloudStackSupporting Hyper-V 3.0 on Apache CloudStack
Supporting Hyper-V 3.0 on Apache CloudStackDonal Lafferty
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby TeamArto Artnik
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
A Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to BluemixA Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to Bluemixibmwebspheresoftware
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivAleksey Asiutin
 

Semelhante a Cloud Foundry Open Tour China (english) (20)

Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
 
Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?
 
Serverless and React
Serverless and ReactServerless and React
Serverless and React
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
qewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle Tierqewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle Tier
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
XS Japan 2008 Xen Mgmt English
XS Japan 2008 Xen Mgmt EnglishXS Japan 2008 Xen Mgmt English
XS Japan 2008 Xen Mgmt English
 
ContainerDayVietnam2016: Docker for JS Developer
ContainerDayVietnam2016: Docker for JS DeveloperContainerDayVietnam2016: Docker for JS Developer
ContainerDayVietnam2016: Docker for JS Developer
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetes
 
DevOps and Hybrid Applications: What You Need to Know
DevOps and Hybrid Applications: What You Need to KnowDevOps and Hybrid Applications: What You Need to Know
DevOps and Hybrid Applications: What You Need to Know
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and Chef
 
Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...
 
Apache OpenWhisk Serverless Computing
Apache OpenWhisk Serverless ComputingApache OpenWhisk Serverless Computing
Apache OpenWhisk Serverless Computing
 
Supporting Hyper-V 3.0 on Apache CloudStack
Supporting Hyper-V 3.0 on Apache CloudStackSupporting Hyper-V 3.0 on Apache CloudStack
Supporting Hyper-V 3.0 on Apache CloudStack
 
Rack
RackRack
Rack
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
A Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to BluemixA Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to Bluemix
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
 

Último

Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
RAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AIRAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AIUdaiappa Ramachandran
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?SANGHEE SHIN
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServicePicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServiceRenan Moreira de Oliveira
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum ComputingGDSC PJATK
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 

Último (20)

Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
RAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AIRAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AI
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?Do we need a new standard for visualizing the invisible?
Do we need a new standard for visualizing the invisible?
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer ServicePicPay - GenAI Finance Assistant - ChatGPT for Customer Service
PicPay - GenAI Finance Assistant - ChatGPT for Customer Service
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum Computing
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 

Cloud Foundry Open Tour China (english)

  • 1. developers perspective mark lucovsky vp of engineering, cloud foundry
  • 2. agenda •  cloud foundry – PaaS •  sample app: •  polyglot in action •  node •  redis •  json •  ruby •  html5 •  jQuery •  multi-tier •  horizontally scalable •  vmc manifest •  etc. 2 developer perspective v2.0
  • 3. cloud foundry 3 developer perspective v2.0
  • 4. cloud foundry: open paas •  active open source project, liberal license •  infrastructure neutral core, runs on any IaaS/Infra •  extensible runtime/framework, services architecture •  node, ruby, java, scala, erlang, etc. •  postgres, neo4j, mongodb, redis, mysql, rabbitmq •  clouds: raw infra structure, to fully managed (AppFog) •  VMware’s delivery forms •  raw bits and deployment tools on GitHub •  Micro Cloud Foundry •  cloudfoundry.com 4 developer perspective v2.0
  • 5. key abstractions •  applications •  instances •  services •  vmc – cli (based almost 1:1 on control api) 5 developer perspective v2.0
  • 6. hello world: classic $  cat  hw.c   #include  <stdio.h>   main()  {      printf(“Hello  Worldn”);   }   $  cc  hw.c;  ./a.out   6 developer perspective v2.0
  • 7. hello world of the cloud $  cat  hw.rb   require  'rubygems'   require  'sinatra'     $hits  =  0   get  '/'  do      $hits  =  $hits  +  1      "Hello  World  -­‐  #{$hits}"   end   $  vmc  push  hw   7 developer perspective v2.0
  • 8. cc  hw.c vmc  push  hw 8 developer perspective v2.1
  • 9. hello world of the cloud: scale it up $  vmc  instances  hw  10     get  '/'  do      $hits  =  $hits  +  1      "Hello  World  -­‐  #{$hits}"   end     #  above  code  is  broken  for  >  1  instance   #  move  hit  counter  to  redis,  hi-­‐perf  K/V  store   $  vmc  create-­‐service  redis  –bind  hw     get  '/'  do      $hits  =  $redis.incr(‘hits’)      "Hello  World  -­‐  #{$hits}"   end   9 developer perspective v2.0
  • 10. 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   10 developer perspective v2.0
  • 11. sample app 11 developer perspective v2.0
  • 12. 12 developer perspective v2.0
  • 13. stac2: load generation system - jQuery, jQuery UI json-p stac2 - 2 x 128mb - haml templates frontend - ruby 1.8.7, sinatra - 100% JS based UI smtp http json email - 16 x 128mb* api server - node.JS, 0.6.8 reports rpush redis api redis blpop redis api blpop - 96 x 128mb - 16 x 128mb* - ruby 1.8.7, sinatra vmc worker http worker - node.JS, 0.6.8 * - api server and http worker share the same node.JS process/instance 13 developer perspective v2.0
  • 14. deployment instructions $ cd ~/stac2 $ vmc push 14 developer perspective v2.0
  • 15. how is this possible? $  cd  ~/stac2;  cat  manifest.yml   applications:      ./nabh:          instances:  16          mem:  128M          runtime:  node06          url:  ${name}.${target-­‐base}          services:              nab-­‐redis:                  type:  :redis   ./nabv:          instances:  96          mem:  128M            runtime:  ruby18          url:  ${name}.${target-­‐base}          services:              nab-­‐redis:                  type:  :redis   ./stac2:          instances:  2          mem:  128M            runtime:  ruby18          url:  ${name}.${target-­‐base}   15 developer perspective v2.0
  • 16. design tidbits •  producer/consumer pattern using rpush/blpop •  node.JS: multi-server and high performance async i/o •  caldecott – aka vmc tunnel for debugging •  redis sorted sets for stats collection •  redis expiring keys for rate calculation 16 developer perspective v2.0
  • 17. producer/consumer •  core design pattern •  found at the heart of many complex apps classic mode: - thread pools - semaphore/mutex, completion ports, etc. - scalability limited to visibility of the work queue producer work work queue work consumer cloud foundry mode: - instance pools - redis rpush/blpop, rabbit queues, etc. - full horizontal scalability, cloud scale 17 developer perspective v2.0
  • 18. producer/consumer: code //  producer   function  commit_item(queue,  item)  {      //  push  the  work  item  onto  the  proper  queue        redis.rpush(queue,  item,  function(err,  data)  {            //  optionally  trim  the  queue,  throwing  away          //  data  as  needed  to  ensure  the  queue  does          //  not  grow  unbounded          if  (!err  &&  data  >  queueTrim)  {              redis.ltrim(queue,  0,  queueTrim-­‐1);          }            });   }     //  consumer   function  worker()  {      //  blocking  wait  for  workitems      blpop_redis.blpop(queue,  0,  function(err,  data)  {                    //  data[0]  ==  queue,  data[1]  ==  item          if  (!err)  {              doWork(data[1]);          }          process.nextTick(worker);            });   }     18 developer perspective v2.0
  • 19. node.JS multi-server: http API server //  the  api  server  handles  two  key  load  generation  apis   //  /http  –  for  http  load,  /vmc  for  Cloud  Foundry  API  load   var  routes  =  {“/http”:  httpCmd,  “/vmc”:  vmcCmd}     //  http  api  server  booted  by  app.js,  passing  redis  client   //  and  Cloud  Foundry  instance     function  boot(redis_client,  cfinstance)  {      var  redis  =  redis_client;            function  onRequest(request,  response)  {          var  u  =  url.parse(request.url);          var  path  =  u.pathname;          if  (routes[path]  &&  typeof  routes[path]  ==  ‘function’)  {              routes[path](request,  response);          }  else  {              response.writeHead(404,  {‘Content-­‐Type’:  ‘text/plain’});              response.write(‘404  Not  Found’);              response.end();          }      }      server  =  http.createServer(onRequest).listen(cfinstance[‘port’]);   }   19 developer perspective v2.0
  • 20. node.JS multi-server: blpop server var  blpop_redis  =  null;   var  status_redis  =  null;   var  cfinstance  =  null;     //  blpop  server  handles  work  requests  for  http  traffic   //  that  are  placed  on  the  queue  by  the  http  API  server   //  another  blpop  server  sits  in  the  ruby/sinatra  VMC  server   function  boot(r1,  r2,  cfi)  {      //  multiple  redis  clients  due  to  concurrency  constraints      blpop_redis  =  r1;      status_redis  =  r2;      cfinstance  =  cfi;      worker();   }     //  this  is  the  blpop  server  loop   function  worker()  {      blpop_redis.blpop(queue,  0,  function(err,  data)  {          if  (!err)  {              doWork(data[1]);          }          process.nextTick(worker);            });   }     20 developer perspective v2.0
  • 21. caldecott: aka vmc tunnel #  create  a  caldecott  tunnel  to  the  redis  server   $  vmc  tunnel  nab-­‐redis  redis-­‐cli   Binding  Service  [nab-­‐redis]:  OK   …   Launching  'redis-­‐cli  -­‐h  localhost  -­‐p  10000  -­‐a  ...’         #  enumerate  the  keys  used  by  stac2   redis>  keys  vmc::staging::*   1)  “vmc::staging::actions::time_50”   2)  “vmc::staging::active_workers”   …     #  enumerate  actions  that  took  less  that  50ms   redis>  zrange  vmc::staging::actions::time_50  0  -­‐1  withscores   1)  “delete_app”   2)  “1”   3)  “login”   4)  “58676”   5)  “info”   6)  “80390”     #  see  how  many  work  items  we  dumped  due  to  concurrency  constraint   redis>  get  vmc::staging::wastegate   “7829”       21 developer perspective v2.0
  • 22. redis sorted sets for stats collection #  log  action  into  a  sorted  set,  net  result  is  set  contains   #  actions  and  the  number  of  times  the  action  was  executed   #  count  total  action  count,  and  also  per  elapsed  time  bucket   def  logAction(action,  elapsedTimeBucket)        #  actionKey  is  the  set  for  all  counts      #  etKey  is  the  set  for  a  particular  time  bucket  e.g.,  _1s,  _50ms      actionKey  =  “vmc::#{@cloud}::actions::action_set”      etKey  =  “vmc::#{@cloud}::actions::times#{elapsedTimeBucket}”      @redis.zincrby  actionKey,  1,  action      @redis.zincrby  etKey,  1,  action   end     #  enumerate  actions  and  their  associated  count   redis>  zrange  vmc::staging::actions::action_set  0  -­‐1  withscores   1)  “login”   2)  “212092”   3)  “info”   4)  “212093”     #  enumerate  actions  that  took  between  400ms  and  1s   redis>  zrange  vmc::staging::actions::time_400_1s  0  -­‐1  withscores   1)  “create-­‐app”   2)  “14”   3)  “bind-­‐service”   4)  “75”     22 developer perspective v2.0
  • 23. redis incrby and expire for rate calcs #  to  calculate  rates  (e.g.,  4,000  requests  per  second)   #  we  use  plain  old  redis.incrby.  the  trick  is  that  the     #  key  contains  the  current  1sec  timestamp  as  it’s  suffix  value   #  all  activity  that  happens  within  this  1s  period  accumulates   #  in  that  key.  by  setting  an  expire  on  the  key,  the  key  is     #  automatically  deleted  10s  after  last  write   def  logActionRate(cloud)      tv  =  Time.now.tv_sec      one_s_key  =  "vmc::#{cloud}::rate_1s::#{tv}"        #  increment  the  bucket  and  set  expires,  key      #  will  eventually  expires  Ns  after  the  last  write      @redis.incrby  one_s_key,  1      @redis.expire  one_s_key,  10   end     #  return  current  rate  by  looking  at  the  bucket  for  the  previous     #  one  second  period.  by  looking  further  back  and  averaging,  we     #  can  smooth  the  rate  calc   def  actionRate(cloud)      tv  =  Time.now.tv_sec  -­‐  1      one_s_key  =  "vmc::#{cloud}::rate_1s::#{tv}"      @redis.get  one_s_key   end     23 developer perspective v2.0
  • 24. 24 developer perspective v2.0
  • 25. www.cloudfoundry.com/jobs 25 developer perspective v2.0