Your SlideShare is downloading. ×
0
From	  Web	  sites	  to	  Web	  apps	  	                in	  Rails	                  Ambert	  Ho	                         ...
What	  is	  a	  web	  site	  vs.	  web	  app?	  • Content	  consump7on	  vs.	  interac7on?	   	        • Facebook	  and	  ...
Emerging	  importance	  of	  ‘real7me’	       I	  use	  this	  term	  loosely	  since	  ‘real7me’	  has	       predefined	 ...
How	  does	  it	  work?	  
What	  is	  comet/reverse	  ajax/ajax	   push?	  (‘push’	  data	  to	  client)	     • Long	  polling	      	     • Websock...
Details:	  how	  to	  actually	  go	  about	                doing	  this?	   • To	  bolt	  onto	  Rails	  you	  need:	    ...
Juggernaut	     • hCps://github.com/maccman/juggernaut	      	           • Used	  to	  be	  EM,	  now	  uses	  Node.js	   ...
Event	  Loop	          (For	  the	  real7me	  endpoint)                	  	  • Why	  not	  use	  Rails	  all	  the	  way?	...
Review	  on	  ‘what	  does	  what’	  Rails,	  using	  the	  Redis	  gem	  or	  some	                                      ...
Alterna7ves	  • Pusher	   	     • Don’t	  have	  to	  setup	  Node	  and	  Redis	      	          • Considera7on	  with	  ...
Slides http://www.slideshare.net/ambertchContact  ambert@opzi.comDiscussion/Questions?
Upcoming SlideShare
Loading in...5
×

Realtime web apps rails

2,283

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,283
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
22
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Realtime web apps rails"

  1. 1. From  Web  sites  to  Web  apps     in  Rails   Ambert  Ho   *all  images  were  has7ly  ripped   off  the  internet  and  belong  to   their  respec7ve  owner  
  2. 2. What  is  a  web  site  vs.  web  app?  • Content  consump7on  vs.  interac7on?     • Facebook  and  TwiCer  blur  the  line    
  3. 3. 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  
  4. 4. How  does  it  work?  
  5. 5. What  is  comet/reverse  ajax/ajax   push?  (‘push’  data  to  client)   • Long  polling     • Websockets     • (flash  sockets  too)    
  6. 6. 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”  
  7. 7. 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  
  8. 8. 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  
  9. 9. 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  
  10. 10. 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)  
  11. 11. Slides http://www.slideshare.net/ambertchContact ambert@opzi.comDiscussion/Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×