Successfully reported this slideshow.

UCLUG TorqueBox - 03/08/2011

1,277 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

UCLUG TorqueBox - 03/08/2011

  1. 1. Toby Crawley UCLUG Creative  Commons  BY-­SA  3.0 March 2011Thursday, March 10, 2011
  2. 2. whoami • C  >  Java  >  PHP  >  Java  >  Ruby  >   Java? • emacs,  though  I’ve  heard  of  vi • Red  Hat  Senior  Engineer   • proud  member  ofThursday, March 10, 2011
  3. 3. Agenda • High-­level  structure  and  TorqueBox   setup • Web,  Messaging,  Scheduling,   Services,  ClusteringThursday, March 10, 2011
  4. 4. TorqueBox the power of JBoss with the expressiveness of RubyThursday, March 10, 2011
  5. 5. TorqueBox:  what? • A  “real”  app  server  for  Ruby • Founded  in  2008 • Bob  McWhirter’s  “labor  of  love” • 100%  open-­source,  LGPL  license • Reflects  a  strong  commitment  to   Ruby  from  Red  HatThursday, March 10, 2011
  6. 6. TorqueBox:  why? • “Native”  support  for  Rack  apps • Built-­in  background  processing • Built-­in  scheduling • Built-­in  clustering • Easily  scalable • Optionally  enterpriseyThursday, March 10, 2011
  7. 7. JRuby a good idea done wellThursday, March 10, 2011
  8. 8. JRuby:  why? • Very  fast  runtime • Real  threads • Java  libraries • Java  tools • Healthy  communityThursday, March 10, 2011
  9. 9. JRuby:  why  not? • Slower  start  up • Native  gems • FFI • C  extension  support • Some  Ruby  libs  not  thread-­safeThursday, March 10, 2011
  10. 10. JBoss  AS the enterprisey good partsThursday, March 10, 2011
  11. 11. I  promise... • No  XML   • No  Java  * • No  war  files  * • Only  Ruby  and  YAML * Unless you really want toThursday, March 10, 2011
  12. 12. JBoss  AS6 • Tomcat  for  web • Infinispan  for  caching • HornetQ  for  messaging • Quartz  for  scheduling • PicketBox  for  authentication • mod_cluster  for  clusteringThursday, March 10, 2011
  13. 13. AS  =  Application  Server • Not  just  “web  server  +  interpreter” • More  like  initd  than  httpd • Can  host  multiple,  disparate  apps   simultaneously • Provides  basic  services  to  all  the   apps  it  hostsThursday, March 10, 2011
  14. 14. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed • anything  removed  from   deploy/  will  get   undeployed • anything  updated  in   deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archivesThursday, March 10, 2011
  15. 15. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed deployment   • anything  removed  from   descriptors deploy/  will  get   undeployed • anything  updated  in   deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archivesThursday, March 10, 2011
  16. 16. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed deployment   • anything  removed  from   descriptors deploy/  will  get   undeployed • anything  updated  in   deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archivesThursday, March 10, 2011
  17. 17. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed • anything  removed  from   deploy/  will  get   undeployed zip  files   • anything  updated  in   (archives) deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archivesThursday, March 10, 2011
  18. 18. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed • anything  removed  from   deploy/  will  get   undeployed zip  files   • anything  updated  in   (archives) deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archivesThursday, March 10, 2011
  19. 19. Setting  Up  TorqueBox in 3 easy steps!Thursday, March 10, 2011
  20. 20. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATHThursday, March 10, 2011
  21. 21. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATHThursday, March 10, 2011
  22. 22. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATHThursday, March 10, 2011
  23. 23. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip Make  sure  the  jruby   found  in  your  path  is  in   $JRUBY_HOME/bin. $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATHThursday, March 10, 2011
  24. 24. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip Make  sure  the  jruby   found  in  your  path  is  in   $JRUBY_HOME/bin. $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATHThursday, March 10, 2011
  25. 25. easy  install $  jruby  -­S  gem  install  bundler $  jruby  -­S  gem  install  rails $  jruby  -­S  gem  install  sinatraThursday, March 10, 2011
  26. 26. rake  tasks Rakefile require  "torquebox-­rake-­support"Thursday, March 10, 2011
  27. 27. rake  tasks rake  torquebox:run        Run  TorqueBox  server rake  torquebox:deploy[context_path]        Deploy  the  app  in  the  current  directory rake  torquebox:undeploy        Undeploy  the  app  in  the  current  directoryThursday, March 10, 2011
  28. 28. rake  tasks Start  torquebox:run  in  its  own   shell  and  leave  it  running.  Instead   of  script/server  or  shotgun   or  thin  or  whatever  else,   use  torquebox:deploy.Thursday, March 10, 2011
  29. 29. deployment  descriptors torquebox:deploy  creates   a  deployment  descriptor  in  the   JBoss  deploy/  directoryThursday, March 10, 2011
  30. 30. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: context: myapp host: www.yourhost.com static: public rackup: config.ru environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  31. 31. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: The  fully-­qualified   context: myapp host: www.yourhost.com path  to  the  app.     static: public This  will  be  the  value   environment: of  either   RAILS_ROOT  or   MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com RACK_ROOTThursday, March 10, 2011
  32. 32. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: The  fully-­qualified   context: myapp host: www.yourhost.com path  to  the  app.     static: public This  will  be  the  value   environment: of  either   RAILS_ROOT  or   MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com RACK_ROOTThursday, March 10, 2011
  33. 33. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: context: myapp The  runtime  mode  of   host: www.yourhost.com static: public the  app.    This  will  be   environment: either  RAILS_ENV   or  RACK_ENV MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  34. 34. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: context: myapp The  runtime  mode  of   host: www.yourhost.com static: public the  app.    This  will  be   environment: either  RAILS_ENV   or  RACK_ENV MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  35. 35. deployment  descriptors The  app’s  context  path   deploy/myapp-­knob.yml “sub  URI”): (or   http://localhost:8080/myapp application: Can  be  set  via  rake: root: rake  torquebox:deploy[myapp] /path/to/myapp env: development The  default  is  root: web: http://localhost:8080/ context: myapp host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  36. 36. deployment  descriptors The  app’s  context  path   deploy/myapp-­knob.yml “sub  URI”): (or   http://localhost:8080/myapp application: Can  be  set  via  rake: root: rake  torquebox:deploy[myapp] /path/to/myapp env: development The  default  is  root: web: http://localhost:8080/ context: myapp host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  37. 37. deployment  descriptors deploy/myapp-­knob.yml application: A  list  of  virtual   root: /path/to/myapp env: development hostnames  to  which   web: to  bind  the  app. context: myapp host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  38. 38. deployment  descriptors deploy/myapp-­knob.yml application: A  list  of  virtual   root: /path/to/myapp env: development hostnames  to  which   web: to  bind  the  app. context: myapp host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  39. 39. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development The  location  of  the   web: app’s  static   context: myapp content,  either   host: www.yourhost.com absolute  or  relative   static: public environment: to  the  app’s  root. MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  40. 40. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development The  location  of  the   web: app’s  static   context: myapp content,  either   host: www.yourhost.com absolute  or  relative   static: public environment: to  the  app’s  root. MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  41. 41. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp Any  environment   env: development web: variables  required   context: myapp by  the  app. host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  42. 42. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp Any  environment   env: development web: variables  required   context: myapp by  the  app. host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.comThursday, March 10, 2011
  43. 43. deployment  descriptors • config/torquebox.yml   • internal  descriptors  have  the   same  structure  as  the   external  ones  in  deploy/ • may  be  used  to  provide  your   own  reasonable  defaultsThursday, March 10, 2011
  44. 44. Web make rack, not warThursday, March 10, 2011
  45. 45. jruby-­rack • All  rack-­based  frameworks   supported:  rails,  sinatra,  etc • No  packaging  required:  apps  deploy   from  where  they  sit  on  disk • No  redeploy  necessary  to  see   changes  when  using  rack  reloading   or  rails  development  modeThursday, March 10, 2011
  46. 46. database  connectivity Gemfile gem  "activerecord-­jdbc-­adapter" gem  "jdbc-­postgres" #  gem  "jdbc-­sqlite3" #  gem  "jdbc-­mysql"Thursday, March 10, 2011
  47. 47. rails  template • Adds  TorqueBox  rake  tasks • Adds  the  JDBC  sqlite3  gems • Adds  TorqueBox  session_store • Adds  Backgroundable  moduleThursday, March 10, 2011
  48. 48. my  first  rails  app $  jruby  -­S  gem  install  bundler  rails $  jruby  -­S  rails  new  myapp  -­m          $TORQUEBOX_HOME/share/rails/template.rb $  cd  myapp $  jruby  -­S  bundle  install $  jruby  -­S  rake  torquebox:deployThursday, March 10, 2011
  49. 49. Messaging asynchronicityThursday, March 10, 2011
  50. 50. lots  of  optionsThursday, March 10, 2011
  51. 51. lots  of  options RabbitMQ cron Resque BackgroundDRb workling CronEdit BackgroundJob Kestral rufus-scheduler JobFu Ap4r Amazon SQS async_observer Taskr Sparrow Background-Fu beanstalkd DelayedJob RailsCron Open4 Conveyor WorkerQueue daemons rake ActiveMQ starling Spawn ActiveMessagingThursday, March 10, 2011
  52. 52. TorqueBox::Messaging • JMS  (Java  Message  Service)   is  an  API  for  messaging • implementation HornetQ  is  the  JBoss  JMS  Thursday, March 10, 2011
  53. 53. TorqueBox::Messaging • No  extra  tables  in  your  database • No  external  system  to  manage • Little  to  no  config  required  at  all • System  gets  redeployed  w/app • Efficient  loading  of  rails  environment • Automatic  load  balancing  and  retries • Works  on  Windows,  if  you  careThursday, March 10, 2011
  54. 54. Tasks app/tasks/email_task.rb class  EmailTask  <  TorqueBox::Messaging::Task    def  welcome(payload)        person  =  Person.find_by_id(payload[:id])        if  person            #  send  the  email            person.welcomed  =  true            person.save!        end    end endThursday, March 10, 2011
  55. 55. Tasks app/tasks/email_task.rb class  EmailTask  <  TorqueBox::Messaging::Task    def  welcome(payload)        person  =  Person.find_by_id(payload[:id])        if  person            #  send  the  email            person.welcomed  =  true            person.save!        end    end endThursday, March 10, 2011
  56. 56. Tasks app/tasks/email_task.rb class  EmailTask  <  TorqueBox::Messaging::Task    def  welcome(payload)        person  =  Person.find_by_id(payload[:id])        if  person            #  send  the  email            person.welcomed  =  true            person.save!        end    end endThursday, March 10, 2011
  57. 57. Tasks app/tasks/email_task.rb class  EmailTask  <  TorqueBox::Messaging::Task    def  welcome(payload)        person  =  Person.find_by_id(payload[:id])        if  person            #  send  the  email            person.welcomed  =  true            person.save!        end    end endThursday, March 10, 2011
  58. 58. Tasks app/controllers/people_controller.rb class  PeopleController  <  ApplicationController    def  create        @person  =  Person.new(params[:person])        respond_to  do  |format|            if  @person.save                EmailTask.async(:welcome,  :id  =>  person.id)                #  respond  appropriately            end        end    end endThursday, March 10, 2011
  59. 59. Tasks app/controllers/people_controller.rb class  PeopleController  <  ApplicationController    def  create        @person  =  Person.new(params[:person])        respond_to  do  |format|            if  @person.save                EmailTask.async(:welcome,  :id  =>  person.id)                #  respond  appropriately            end        end    end endThursday, March 10, 2011
  60. 60. Tasks Call  them  from  your   controllers,  models,  and   observers,  or  even  other   tasks.  Even  in  non-­Rails   apps!Thursday, March 10, 2011
  61. 61. Backgroundable Inspired  by  DelayedJob’s   handle_asynchronously,   it’s  trivial  to  create  implicit   background  Tasks.Thursday, March 10, 2011
  62. 62. Backgroundable lib/something.rb include  TorqueBox::Messaging   class  Something    include  Backgroundable    always_background  :foo    def  foo;;  end    def  bar;;  end end ... @something.foo @something.background.barThursday, March 10, 2011
  63. 63. Backgroundable lib/something.rb include  TorqueBox::Messaging   class  Something    include  Backgroundable    always_background  :foo    def  foo;;  end    def  bar;;  end end ... @something.foo @something.background.barThursday, March 10, 2011
  64. 64. Backgroundable lib/something.rb include  TorqueBox::Messaging   class  Something    include  Backgroundable    always_background  :foo    def  foo;;  end    def  bar;;  end end ... @something.foo @something.background.barThursday, March 10, 2011
  65. 65. Backgroundable lib/something.rb include  TorqueBox::Messaging   class  Something    include  Backgroundable    always_background  :foo    def  foo;;  end    def  bar;;  end end ... @something.foo @something.background.barThursday, March 10, 2011
  66. 66. Backgroundable app/models/slow_poke.rb class  SlowPoke  <  ActiveRecord::Base    always_background  :takes_forever    def  takes_forever;;  end    def  might_take_awhile;;  end end @slowpoke.takes_forever @slowpoke.background.might_take_awhileThursday, March 10, 2011
  67. 67. Queues Tasks  are  built  on  top  of   Queues.    Of  course,  you  may   build  your  own  messaging   based  apps  by  defining  your   own  Queues,  Topics,  and  their   message  Processors  yourself.Thursday, March 10, 2011
  68. 68. Queues config/torquebox.yml queues:    /queues/questions:    /queues/answers:        durable:  falseThursday, March 10, 2011
  69. 69. Processors You  can  create  a  processor   class  to  receive  messages   from  a  Topic  or  QueueThursday, March 10, 2011
  70. 70. Processors config/torquebox.yml messaging: /topics/print: - PrintHandler - PopularHandler concurrency: 5 /queues/students: PrintHandler: config: color: trueThursday, March 10, 2011
  71. 71. Processors config/torquebox.yml messaging: /topics/print: - PrintHandler - PopularHandler concurrency: 5 /queues/students: PrintHandler: config: color: trueThursday, March 10, 2011
  72. 72. Processors config/torquebox.yml messaging: /topics/print: - PrintHandler - PopularHandler concurrency: 5 /queues/students: PrintHandler: config: color: trueThursday, March 10, 2011
  73. 73. Processors config/torquebox.yml messaging: /topics/print: - PrintHandler - PopularHandler concurrency: 5 /queues/students: PrintHandler: config: color: trueThursday, March 10, 2011
  74. 74. Processors app/models/print_handler.rb include  TorqueBox::Messaging class  PrintHandler  <  MessageProcessor    def  on_message(body)        puts  "Processing  #{body}  of  #{message}"    end    def  configure(opts)        @color  =  opts[color]    end endThursday, March 10, 2011
  75. 75. Queues  (again) But  how  do  you  send  a   message?Thursday, March 10, 2011
  76. 76. Queues example include  TorqueBox::Messaging questions  =  Queue.new  /queues/questions answers  =  Queue.new  /queues/answers   Thread.new  do    questions.publish  "What  time  is  it?"    puts  answers.receive(  :timeout  =>  1000  ) end   puts  questions.receive answers.publish  Time.nowThursday, March 10, 2011
  77. 77. Queues example include  TorqueBox::Messaging questions  =  Queue.new  /queues/questions answers  =  Queue.new  /queues/answers   Thread.new  do    questions.publish  "What  time  is  it?"    puts  answers.receive(  :timeout  =>  1000  ) end   puts  questions.receive answers.publish  Time.nowThursday, March 10, 2011
  78. 78. Queues example include  TorqueBox::Messaging questions  =  Queue.new  /queues/questions answers  =  Queue.new  /queues/answers   Thread.new  do    questions.publish  "What  time  is  it?"    puts  answers.receive(  :timeout  =>  1000  ) end   puts  questions.receive answers.publish  Time.nowThursday, March 10, 2011
  79. 79. Queues example include  TorqueBox::Messaging questions  =  Queue.new  /queues/questions answers  =  Queue.new  /queues/answers   Thread.new  do    questions.publish  "What  time  is  it?"    puts  answers.receive(  :timeout  =>  1000  ) end   puts  questions.receive answers.publish  Time.nowThursday, March 10, 2011
  80. 80. Topics • behavior  is  different,  but  interface  is   the  same. • all  subscribers  of  a  topic  see  each   message,  but  only  one  subscriber   will  see  any  message  from  a  queue   • use  topics:  section  of   torquebox.yml  to  define  topics • use  TorqueBox::Messaging::TopicThursday, March 10, 2011
  81. 81. Scheduling get regular laterThursday, March 10, 2011
  82. 82. Jobs app/jobs/newsletter_sender.rb class  NewsletterSender      def  run()        subscriptions  =  Subscription.find(:all)        subscriptions.each  do  |e|            send_newsletter(  e  )        end    end   endThursday, March 10, 2011
  83. 83. Jobs config/torquebox.yml jobs:    monthly_newsletter:        description:  first  of  month        job:  NewsletterSender        cron:  ‘0  0  0  1  *  ?’        process_tps_reports:        job:  TPSReportProcessor        cron:  ‘0  0  0  0  MON  ?’Thursday, March 10, 2011
  84. 84. Jobs “Fire  every  half  hour  from  10am  until  1pm   on  the  third  Friday  of  each  month” 0 */30 10-13 ? * FRI#3 Seconds Minutes Hours DOM Month DOW Year 1-7 1-12 1970- 1-31 SUN- 0-59 0-59 0-23 JAN- 2099 ?LW SAT DEC empty ?L#Thursday, March 10, 2011
  85. 85. Jobs • More  portable.  What  is  the  first  day   of  the  week  on  BSD  again?    What’s   cron  on  Windows? • Self  contained  within  the  app.    No   external  systems  to  manage  and   keep  in  sync. • Full  rails  environment  loaded  and   available.Thursday, March 10, 2011
  86. 86. Services run along, lil’ daemonThursday, March 10, 2011
  87. 87. Services Long-­running,  non-­web   “daemons”  that  share  the   runtime  environment  and   deployment  lifecycle  of   your  app.Thursday, March 10, 2011
  88. 88. Services • Represented  as  a  class  with   optional  initialize(Hash),   start()  and  stop()  methods,   which  should  each  return  quickly. • Typically  will  start  a  long-­running   loop  in  a  thread  and  respond  to   external  events. • Configured  via  services:  section  in   torquebox.ymlThursday, March 10, 2011
  89. 89. Services config/torquebox.yml services:    IrcBot:        server:  freenode.net        channel:  #torquebox        publish:  /topics/irc    MyMudServer:    SomeOtherService:Thursday, March 10, 2011
  90. 90. Services app/services/my_service.rb class  MyService    def  initialize(opts={})        name  =  opts[:publish]        @queue  =  Queue.new(name)    end    def  start          Thread.new  {  run  }      end    def  stop          @done  =  true    end endThursday, March 10, 2011
  91. 91. Services app/services/my_service.rb class  MyService    def  initialize(opts={})        name  =  opts[:publish]        @queue  =  Queue.new(name)    end    def  start          Thread.new  {  run  }      end    def  stop          @done  =  true    end endThursday, March 10, 2011
  92. 92. Services app/services/my_service.rb class  MyService    def  initialize(opts={})        name  =  opts[:publish]        @queue  =  Queue.new(name)    end    def  start          Thread.new  {  run  }      end    def  stop          @done  =  true    end endThursday, March 10, 2011
  93. 93. Services app/services/my_service.rb class  MyService    def  initialize(opts={})        name  =  opts[:publish]        @queue  =  Queue.new(name)    end    def  start          Thread.new  {  run  }      end    def  stop          @done  =  true    end endThursday, March 10, 2011
  94. 94. Services app/services/my_service.rb class  MyService    def  run        until  @done            @queue.publish(Time.now)            sleep(1)          end    end endThursday, March 10, 2011
  95. 95. Services app/services/my_service.rb class  MyService    def  run        until  @done            @queue.publish(Time.now)            sleep(1)          end    end endThursday, March 10, 2011
  96. 96. Clustering less failure fasterThursday, March 10, 2011
  97. 97. out-­of-­the-­box • JBoss  provides • session  replication • load-­balanced  messaging • mod_cluster  provides • session  affinity • intelligent  load-­balanced  web • failoverThursday, March 10, 2011
  98. 98. mod_cluster A  reverse  proxy  implemented   as  an  Apache  module  with   JBoss  awareness.  Constantly   gathers  load  statistics  and   deployment  availability  for   intelligent  request  distribution.Thursday, March 10, 2011
  99. 99. mod_clusterThursday, March 10, 2011
  100. 100. mod_cluster • Dynamic  configuration • Server-­side  load  factor  calculation • Fine-­grained  web  app  lifecycle • AJP  (Apache  JServ  Protocol)  is   optional.  HTTP[S]  is  also  supported.Thursday, March 10, 2011
  101. 101. Caching hot off of the press!Thursday, March 10, 2011
  102. 102. Caching • Infinispan  cache  store • non-­clustered: • local • clustered: • invalidation • replicated • distributedThursday, March 10, 2011
  103. 103. Caching config/application.rb config.cache_store  =   :torque_box_store,  :mode  =>  :local #  or config.cache_store  =   ActiveSupport::Cache::TorqueBoxStore.new (  :mode  =>  :local  )Thursday, March 10, 2011
  104. 104. Other  Cool  Stuff well, we think it’s coolThursday, March 10, 2011
  105. 105. Cool  Stuff • StompBox  -­  git  based  deploys • BackStage  -­  see  behind  the  curtain • Built  in  authentication • Benchmarking/speed  improvementsThursday, March 10, 2011
  106. 106. Live  Demo wish me luckThursday, March 10, 2011
  107. 107. Resources • http://torquebox.org • #torquebox  on  freenode • https://github.com/torquebox • http://twitter.com/torquebox • http://projectodd.org • https://github.com/tobias/ torquebox_rails_sampleThursday, March 10, 2011
  108. 108. Thanks! questions?Thursday, March 10, 2011

×