Realtime web apps rails
Upcoming SlideShare
Loading in...5
×
 

Realtime web apps rails

on

  • 2,461 views

 

Statistics

Views

Total Views
2,461
Views on SlideShare
2,457
Embed Views
4

Actions

Likes
2
Downloads
21
Comments
0

1 Embed 4

http://www.hanrss.com 4

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Realtime web apps rails Realtime web apps rails Presentation Transcript

    • From  Web  sites  to  Web  apps     in  Rails   Ambert  Ho   *all  images  were  has7ly  ripped   off  the  internet  and  belong  to   their  respec7ve  owner  
    • What  is  a  web  site  vs.  web  app?  • Content  consump7on  vs.  interac7on?     • Facebook  and  TwiCer  blur  the  line    
    • Emerging  importance  of  ‘real7me’   I  use  this  term  loosely  since  ‘real7me’  has   predefined  meanings  in  terms  of  RTOS   • Applica7ons  should  change  state     regardless  of  interac7on   • Even  for  content  sites:     • TwiCer  and  Google  News  update     themselves  while  you  look  at  it   • Same  with  Facebook  wall,  plus  FB     no7fica7ons   • Previously,  ‘real7me’  primarily  used     for  chat  
    • How  does  it  work?  
    • What  is  comet/reverse  ajax/ajax   push?  (‘push’  data  to  client)   • Long  polling     • Websockets     • (flash  sockets  too)    
    • Details:  how  to  actually  go  about   doing  this?   • To  bolt  onto  Rails  you  need:     1.  A  real7me  endpoint  (more  on  this  later)     2.  Way  to  communicate  with  that  endpoint   3.  Clientside  code  organiza7on  to  process  what  happens     “Gimme  a  real  example”  
    • Juggernaut   • hCps://github.com/maccman/juggernaut     • Used  to  be  EM,  now  uses  Node.js    Juggernaut  logic   Redis   Gem  for  interface   Node.JS  Socket.IO  (server)   Rails   Socket.IO  (client)   Your  JS   Client  
    • Event  Loop   (For  the  real7me  endpoint)    • Why  not  use  Rails  all  the  way?     • Your  web  server  spins  up  a     worker  pool  of  en7re  Rails   instances   • #  persistent  connec7ons  limited  by  #     Rails  instances  that  fit  in  memory   • spinning  up  Rails  also  takes  7me     • BeCer  with  REE  and  CoW     • Event  loops  excel  at  I/O  bound     tasks*   • Lot  of  simple  web  stuff,  par7cularly    *It’s  more  complicated   managing  connec7ons  like  with  ‘real7me’,  If  you  want  to  know  why   is  I/O  bound  research  concurrency  on  JVM  
    • Review  on  ‘what  does  what’  Rails,  using  the  Redis  gem  or  some   Do  it  OOB?  (Net::HTTP  is  wrapper  like  the  Juggernaut  gem,   blocking)  publishes  to  Redis,  and  since  Node.js  is  subscribed  it  gets  the  message,  which  it  boots  to  the  client  through  Socket.IO  –  the  client  then  uses  a  framework  (like  Backbone.js)  to  work  with  the  piece  of  data.   • Backbone  is  designed  towards     working  with  serialized  remote   data  
    • Alterna7ves  • Pusher     • Don’t  have  to  setup  Node  and  Redis     • Considera7on  with  websockets  (HTTP  1.1)  and     servers  proxied  behind  NGINX   • benefits  of  having  it  run  as  a  service,  but  costs     $$$  • Run  the  en7re  app  in  Node.js     • LinkedIn  mobile  is  like  this     • Consider  hos7ng  (Dotcloud,  Heroku,     NodeJitsu)  
    • Slides http://www.slideshare.net/ambertchContact ambert@opzi.comDiscussion/Questions?