Real Time Web - What's that for?

Martyn Loughran
Martyn LoughranCTO at Pusher
Makoto




           RTW – WTF?
         Real Time Web – What’s That For?
         Makoto Inoue - Martyn Loughran
Who are we?
RTW
Exciting
Real Time Web - What's that for?
The big guys already do it


  Google wave
  Facebook live feed
  Twitter
This is our story
Martyn

         Once upon a time...




                               November 2009
Visualise web traffic
    Rack           Sinatra Stats
 Existing app       Collector




                Fancy Visualization
Real Time Web - What's that for?
Under the hood
Nginx HTTP_Push_Module
Long polling
Push handled by separate component
Worked, but fiddly to setup
Makoto
         WebSockets




         http://www.flickr.com/photos/lenaah/2939721384/




                                                          December 2009
WebSockets
HTML5 sub standard
Allows Socket in the browser
Now supported in the ‘non-shite’
browsers
 Chrome & Webkit (nightly)
 There is a library for flash emulation
Ajax vs Comet vs WebSocket
                                         Server
Ajax
(Polling)
                                         Client
                                         Server
Comet
(Long polling)
                                         Client

                                         Server


WebSocket
                                         Client
Javascript API
Martyn
         Server Side




         http://www.flickr.com/photos/lenaah/2939721384/




                                                          December 2009
Fun problems

Concurrent
Stateful
Low latency (sometimes)
Asynchronous servers

  Make all IO non-blocking
  Single thread
  Efficient CPU utilisation
Simple example
Other options
em-websocket
cramp
sunshowers
node.js (js)
Example: Drawing




  http://github.com/markevans/websocket_test
class Connection
          class << self
            def add(websocket)
              connections << websocket
            end

            def all
              connections
            end

            def remove(websocket)
              connections.delete(websocket)
            end

            private

            def connections
              @connections ||= []
            end
          end
        end


Keep connection objects in memory
EventMachine.run {
  EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 3001) do |ws|
      ws.onopen {
        puts "WebSocket connection open"
        Connection.add(ws)
      }

          ws.onclose { Connection.remove(ws) }

          ws.onmessage { |data|
            Connection.all.each do |ws|
              ws.send(data) unless ws == self
            end
          }
    end
}
Demo
We wanted to add it
  to everything




    http://www.flickr.com/photos/10737604@N02/1673136876/

                                                   January 2010
Mandays
Work Schedule Management
TrueStory
Backlog Management
Problems
Data gets stale
People make conflicting changes
This discourages collaboration
Requirements

We didn’t want to re-write everything
Reusable by many apps
Really simple
Our solution
+
Real Time Web - What's that for?
Real Time Web - What's that for?
Real Time Web - What's that for?
Real Time Web - What's that for?
Real Time Web - What's that for?
Look Ma




http://www.flickr.com/photos/jeremystockwell/2691931146/   February 2010
Real Time Web - What's that for?
Real Time Web - What's that for?
Case Study

Adding real time to TrueStory
Data Flow
Inspired by JS events
 Trigger in on place
 Bind in another
$('form#sprint').submit(function(){
  var url = $(this).attr('action');
  var data = $(this).serialize();

  $.ajax({                    def create
    url: url,                   @sprint = Sprint.new(params)
    data: data                  @sprint.save
  });
});                             Pusher['project-1'].trigger
                              ('sprints-create', @sprint.attributes)
                              end

pusher.bind('sprints-create', function(attributes) {
   addSprint(attributes);
})
Stateful client
http://github.com/benpickles/js-model
In memory object client side
Asynchronous persistence (e.g. to a
REST API)
Used on TrueStory - let me show you
var sprint = new Sprint(
   {                          def create
     name: "My Sprint Name"     @sprint = Sprint.new(params)
   }                            @sprint.save
);
sprint.save();                  Pusher['project-1'].trigger
                              ('sprints-create', @sprint.attributes)
                                respond_to do |format|
                                  format.js {
                                    render :json => @sprint.to_json
                                  }
                                end
                              end


pusher.bind('sprints-create', function(attributes) {
   var sprint = new Sprint(attributes);
   Sprint.add(sprint);
})
Makoto
         Look Ma




                   March 2010
Task Management Board
Real Time Web - What's that for?
Debugging
Real Time Web - What's that for?
Booking
Real Time Web - What's that for?
Wife Notifier
Real Time Web - What's that for?
Summary




http://www.flickr.com/photos/blueju38/2767019065/
RTW
            (our take)
More than just chat
Another layer of progressive enhancement
Work well with other HTML5 features
Resources
    WebSockets
•   http://dev.w3.org/html5/websockets

•   http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75

•   http://blog.new-bamboo.co.uk/2009/12/30/brain-dump-of-real-time-web-rtw-and-websocket


    Javascript (Client side)
•   http://blog.new-bamboo.co.uk/2010/2/10/json-event-based-convention-websockets

•   http://blog.new-bamboo.co.uk/2010/3/7/the-js-model-layer


    Ruby (Server side)
•   http://github.com/igrigorik/em-websocket

•   http://github.com/lifo/cramp

•   http://rainbows.rubyforge.org/sunshowers
One more thing...
Questions ?



http://pusherapp.com
    Get hooked!
1 of 56

Recommended

mDevCamp - The Best from Google IO by
mDevCamp - The Best from Google IOmDevCamp - The Best from Google IO
mDevCamp - The Best from Google IOondraz
859 views34 slides
Drupal point of vue by
Drupal point of vueDrupal point of vue
Drupal point of vueDavid Ličen
1K views44 slides
Backbone js by
Backbone jsBackbone js
Backbone jsRohan Chandane
3.2K views54 slides
Deploy meteor in production by
Deploy meteor in productionDeploy meteor in production
Deploy meteor in productionMiro Radenovic
2.5K views25 slides
Nuxt.JS Introdruction by
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS IntrodructionDavid Ličen
2.2K views59 slides
BackboneJS and friends by
BackboneJS and friendsBackboneJS and friends
BackboneJS and friendsScott Cowan
855 views16 slides

More Related Content

What's hot

Introduction to VueJS & Vuex by
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & VuexBernd Alter
856 views26 slides
OpenStack Glance by
OpenStack GlanceOpenStack Glance
OpenStack GlanceDeepti Ramakrishna
3.4K views18 slides
Meteor presentation by
Meteor presentationMeteor presentation
Meteor presentationAndy Bute
607 views15 slides
Ускоряем загрузку картинок вебсокетами by
Ускоряем загрузку картинок вебсокетамиУскоряем загрузку картинок вебсокетами
Ускоряем загрузку картинок вебсокетами2ГИС Технологии
225 views32 slides
Vue.js by
Vue.jsVue.js
Vue.jsBADR
361 views16 slides
Vue 淺談前端建置工具 by
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具andyyou
2.2K views77 slides

What's hot(20)

Introduction to VueJS & Vuex by Bernd Alter
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & Vuex
Bernd Alter856 views
Meteor presentation by Andy Bute
Meteor presentationMeteor presentation
Meteor presentation
Andy Bute607 views
Vue.js by BADR
Vue.jsVue.js
Vue.js
BADR361 views
Vue 淺談前端建置工具 by andyyou
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具
andyyou 2.2K views
Backbone.js slides by Ambert Ho
Backbone.js slidesBackbone.js slides
Backbone.js slides
Ambert Ho3.2K views
[20180226] I understand webpacker perfectly by Yuta Suzuki
[20180226] I understand webpacker perfectly[20180226] I understand webpacker perfectly
[20180226] I understand webpacker perfectly
Yuta Suzuki106 views
Kickstarting Node.js Projects with Yeoman by Patrick Buergin
Kickstarting Node.js Projects with YeomanKickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with Yeoman
Patrick Buergin4.1K views
Realtime web apps rails by Ambert Ho
Realtime web apps railsRealtime web apps rails
Realtime web apps rails
Ambert Ho1.2K views
第一次用 Vue.js 就愛上 [改] by Kuro Hsu
第一次用 Vue.js 就愛上 [改]第一次用 Vue.js 就愛上 [改]
第一次用 Vue.js 就愛上 [改]
Kuro Hsu40K views
Introduction to node.js GDD by Sudar Muthu
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
Sudar Muthu7.3K views
The Mobile Development Landscape by Ambert Ho
The Mobile Development LandscapeThe Mobile Development Landscape
The Mobile Development Landscape
Ambert Ho1.4K views
Openstack glance by SHAMEEM F
Openstack glanceOpenstack glance
Openstack glance
SHAMEEM F301 views
The Complementarity of React and Web Components by Andrew Rota
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
Andrew Rota32.3K views
Whirlwind tour of activiti 7 by Ryan Dawson
Whirlwind tour of activiti 7Whirlwind tour of activiti 7
Whirlwind tour of activiti 7
Ryan Dawson55 views

Viewers also liked

Best Of National Geographic 18407 by
Best Of National Geographic 18407Best Of National Geographic 18407
Best Of National Geographic 18407Laura Pessarrodona Silvestre
286 views42 slides
Remax Listing Presentation by
Remax Listing PresentationRemax Listing Presentation
Remax Listing Presentationmarkfortson
1K views18 slides
Ball State Martial Arts Club Eng213 Promo by
Ball State Martial Arts Club Eng213 PromoBall State Martial Arts Club Eng213 Promo
Ball State Martial Arts Club Eng213 Promokaedenboroug
653 views18 slides
A 2D Spatial Light Modulator for spatio-temporal shaping by
A 2D Spatial Light Modulator for spatio-temporal shapingA 2D Spatial Light Modulator for spatio-temporal shaping
A 2D Spatial Light Modulator for spatio-temporal shapingSentewolf
678 views117 slides
Shift Happens 23665 by
Shift Happens 23665Shift Happens 23665
Shift Happens 23665Omar Francisco Ochoa Salinas, MBA
289 views67 slides
Falke School by
Falke SchoolFalke School
Falke Schoolguestf0ff5e
218 views7 slides

Viewers also liked(12)

Similar to Real Time Web - What's that for?

Nodejs and WebSockets by
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSocketsGonzalo Ayuso
13.5K views35 slides
Introduction to JQuery, ASP.NET MVC and Silverlight by
Introduction to JQuery, ASP.NET MVC and SilverlightIntroduction to JQuery, ASP.NET MVC and Silverlight
Introduction to JQuery, ASP.NET MVC and SilverlightPeter Gfader
7.9K views105 slides
Meteor by
MeteorMeteor
MeteorArshavski Alexander
1.2K views32 slides
Comet with node.js and V8 by
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8amix3k
16.4K views24 slides
Cloud State of the Union for Java Developers by
Cloud State of the Union for Java DevelopersCloud State of the Union for Java Developers
Cloud State of the Union for Java DevelopersBurr Sutter
1.8K views65 slides
Analyzing the Performance of Mobile Web by
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAriya Hidayat
3.5K views55 slides

Similar to Real Time Web - What's that for?(20)

Nodejs and WebSockets by Gonzalo Ayuso
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
Gonzalo Ayuso13.5K views
Introduction to JQuery, ASP.NET MVC and Silverlight by Peter Gfader
Introduction to JQuery, ASP.NET MVC and SilverlightIntroduction to JQuery, ASP.NET MVC and Silverlight
Introduction to JQuery, ASP.NET MVC and Silverlight
Peter Gfader7.9K views
Comet with node.js and V8 by amix3k
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
amix3k16.4K views
Cloud State of the Union for Java Developers by Burr Sutter
Cloud State of the Union for Java DevelopersCloud State of the Union for Java Developers
Cloud State of the Union for Java Developers
Burr Sutter1.8K views
Analyzing the Performance of Mobile Web by Ariya Hidayat
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile Web
Ariya Hidayat3.5K views
soft-shake.ch - Hands on Node.js by soft-shake.ch
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
soft-shake.ch2.3K views
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5 by Sadaaki HIRAI
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Sadaaki HIRAI4.6K views
Meetup Performance by Greg Whalin
Meetup PerformanceMeetup Performance
Meetup Performance
Greg Whalin21.1K views
NTT SIC marketplace slide deck at Tokyo Summit by Toshikazu Ichikawa
NTT SIC marketplace slide deck at Tokyo SummitNTT SIC marketplace slide deck at Tokyo Summit
NTT SIC marketplace slide deck at Tokyo Summit
Toshikazu Ichikawa525 views
Hopping in clouds: a tale of migration from one cloud provider to another by Michele Orselli
Hopping in clouds: a tale of migration from one cloud provider to anotherHopping in clouds: a tale of migration from one cloud provider to another
Hopping in clouds: a tale of migration from one cloud provider to another
Michele Orselli596 views
Speak the Web 15.02.2010 by Patrick Lauke
Speak the Web 15.02.2010Speak the Web 15.02.2010
Speak the Web 15.02.2010
Patrick Lauke1.1K views
Hybrid Apps (Native + Web) via QtWebKit by Ariya Hidayat
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
Ariya Hidayat2.6K views
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020 by Matt Raible
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Choose Your Own Adventure with JHipster & Kubernetes - Denver JUG 2020
Matt Raible187 views
Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14) by Is Antipov
Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14)Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14)
Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14)
Is Antipov2.2K views
Serverless 프레임워크로 Nuxt 앱 배포하기 by Changwan Jun
Serverless 프레임워크로 Nuxt 앱 배포하기Serverless 프레임워크로 Nuxt 앱 배포하기
Serverless 프레임워크로 Nuxt 앱 배포하기
Changwan Jun934 views

Recently uploaded

Uni Systems for Power Platform.pptx by
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptxUni Systems S.M.S.A.
55 views21 slides
Empathic Computing: Delivering the Potential of the Metaverse by
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the MetaverseMark Billinghurst
476 views80 slides
ChatGPT and AI for Web Developers by
ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web DevelopersMaximiliano Firtman
187 views82 slides
Report 2030 Digital Decade by
Report 2030 Digital DecadeReport 2030 Digital Decade
Report 2030 Digital DecadeMassimo Talia
15 views41 slides
Java Platform Approach 1.0 - Picnic Meetup by
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic MeetupRick Ossendrijver
27 views39 slides

Recently uploaded(20)

Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst476 views
DALI Basics Course 2023 by Ivory Egg
DALI Basics Course  2023DALI Basics Course  2023
DALI Basics Course 2023
Ivory Egg16 views
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab19 views
Data-centric AI and the convergence of data and model engineering: opportunit... by Paolo Missier
Data-centric AI and the convergence of data and model engineering:opportunit...Data-centric AI and the convergence of data and model engineering:opportunit...
Data-centric AI and the convergence of data and model engineering: opportunit...
Paolo Missier39 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb13 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker33 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada135 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta19 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson66 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2217 views

Real Time Web - What's that for?