building realtimewebslide

Post on 07-Nov-2014

3.683 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

The real time web is not about adding chat on your website. It's not really about having stock tickers. The most interesting aspect of the realtime web is to be found in augmenting the web that we already know. We can add realtime functionally to our applications as another layer of fidelity. This is our story (New Bamboo, London, UK) of experimenting various real time web technologies and coming up with our own solutions (http://www.pusherapp.com). This is not about explaining how to use our solutions, but about sharing exciting opportunities and new technical challenges HTML5 WebSocket brings when you build real time web.

TRANSCRIPT

Makoto Inoue (@makoto_inoue)

Building Real Time Webリアルタイムウェブができるまで

Friday, 27 August 2010

About - 自己紹介 -

http://truestoryapp.com/ http://pandastream.com/ http://pusherapp.com/

Friday, 27 August 2010

HTML5 WebSocket

Cloud Service

Powered by Ruby

Pusher [púsh・er]【名】【C】

Friday, 27 August 2010

押す人.(A person who pushes stuff)

押すもの[道具].(A tool to push)

《俗》 麻薬密売人.(A drug dealer)

Pusher [púsh・er]【名】【C】

http://ejje.weblio.jp/content/pusher

Friday, 27 August 2010

A:@pusherapp のWebSocket試してみました (I tried Pusher’s WebSocket)

B:麻薬買いました (I bought cocaine)

“I got hooked by Pusher”

Friday, 27 August 2010

“I got hooked by Pusher”

Friday, 27 August 2010

node.js & WebSocket (node.js と WebSocket)

The Ruby’s Counter Attack (逆襲のRuby)

The Birth of Pusher (Pusher誕生)

Growing with Pusher (Pusherを通して学んだ事)

Today’s Topic今日のお題

Friday, 27 August 2010

      & evented worldnode.jsとイベント駆動な世界(Nov 2009)

http://www.slideshare.net/simon/evented-io-based-web-servers-explained-using-bunnies

rows = database.fetch(category = 'news')template = read_file('homepage.html')json = fetc_url('http://.../')

database.fetch(category = 'news', callback)read_file('homepage.html', callback)fetc_url('http://.../', callback)

Blocking - Synchronous

Non Blocking - Asynchronous

Friday, 27 August 2010

http://blog.chromium.org/2009/12/web-sockets-now-available-in-google.html

Web Socket In Google Chrome Google のWebSocket サポート(Dec 2009)

Friday, 27 August 2010

WebSocket Protocol

1. Handshake Request 2. Handshake Response

3. Frame Transportation

Benefits1. Less overhead1. Not releasing connection = good to share state within a session

Friday, 27 August 2010

Benefit (利点)

Less Overhead (少ないオーバーヘッド)

Easy to manage state per session(クッキーいらず)

Server Push (サーバからクライアントへのデータ通知)

Friday, 27 August 2010

Ajax(Polling)

Comet

WebSocket

Ajax vs Comet vs WebSocket

(Long Polling)

Friday, 27 August 2010

Web Sockets Client Side Example クライアントサイドの例

http://blog.chromium.org/2009/12/web-sockets-now-available-in-google.html

var ws = new WebSocket("ws://example.com/service"); ws.onopen = function() { ws.send("message to send"); }; ws.onmessage = function (evt) { var received_msg = evt.data; }; ws.onclose = function() {};

Friday, 27 August 2010

Web Sockets Server Side Example サーバサイドの例(node-websocket-server)

http://github.com/miksago/node-websocket-server/blob/master/examples/echo-server.js

var httpServer = http.createServer(serveFile);var server = ws.createServer({}, httpServer);

server.addListener("connection", function(conn){ conn.send(conn.id, "Connected as: "+conn.id);

conn.addListener("message", function(message){ conn.broadcast(message); });});

server.addListener("close", function(conn){ conn.broadcast("<"+conn.id+"> disconnected");});

server.listen(8000);

node-websocket-server = Micheil Smith

Friday, 27 August 2010

TPS(Tweets Per Second)Example秒速ツイート例

http://blog.new-bamboo.co.uk/2009/12/14/pushing-the-boundary-of-real-time-web-with-twitter-and-xfactor

Friday, 27 August 2010

Current State現在の状況

Chrome,Safari, Firefox(Beta)

Different Draft (75, 76)

Flash fallback for non supported browsers

http://github.com/gimite/web-socket-js

Not for iPhone/iPad ;-(

No Binary(yet)

By Hiroshi Ichikawa

Remy Sharp just made iPhone PhoneGap version for 75(remy)

Friday, 27 August 2010

モビルスーツの性能の違いが、戦力の決定的差でないということを教えてやる!!(ガンダムとの2回戦、シャアの自信に溢れたセリフ。)

http://khaos-gate.blog.so-net.ne.jp/2006-07-20

The Ruby’s Counter Attack逆襲のRuby (Dec 2009)

Matz and Ryan Dahli

Friday, 27 August 2010

Rubyをキメると気持ちイイ。説明できていない!!(RubyKaigi2008)

The Ruby’s Counter Attack逆襲のRuby (Dec 2009)

Matz and Ryan Dahli

Friday, 27 August 2010

Event Machine + WebSocket= em-websocket

http://www.igvita.com/2009/12/22/ruby-websockets-tcp-for-the-browser/

require 'em-websocket' EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |ws| ws.onopen { ws.send "Hello Client!"} ws.onmessage { |msg| ws.send "Pong: #{msg}" } ws.onclose { puts "WebSocket closed" }end

em-websocket = Illya Grigorik

Friday, 27 August 2010

Other Ruby related librariesその他の赤い彗星達

http://github.com/frsyuki/rev-websocket

http://github.com/lifo/cramp

http://rainbows.rubyforge.org/sunshowers/Sunshowers/WebSocket.html

http://github.com/mcolyer/em-websocket-proxy

http://github.com/gimite/web-socket-ruby

rev-websocket = sadayuki furuhashicramp = Pratik Naikrainbows - sunshowers = Eric Wongem-websocket-proxy = Matt Colyerweb-socket-ruby = Hiroshi Ichikawa

Friday, 27 August 2010

How to pick the right one?どれを選べばいいの?

Up to date with the latest draft? (最新ドラフトサポート)

Library or framework? (ライブラリかフレームワークか)

Performance (パフォーマンス)

(Alex MacCaw’s fork has 76 support for Cramp)

Friday, 27 August 2010

Performance

http://github.com/makoto/wsbench

http://bit.ly/9tKdeK

This is example of using 2 small size ec2 instance, making 5000 ~ 20000 number of connections , send 1 message to distribute to all connections, and majored the average of how long it took to be delivered to each connection (DRAFT 75 ONLY)

Friday, 27 August 2010

The Birth of Pusher(Pusher 誕生)

Friday, 27 August 2010

TrueStory

Friday, 27 August 2010

Problem 問題

Data gets stale (データが古くなる)

Conflicts (更新データの衝突)

Discourages collaboration (コラボレーションの障害)

Friday, 27 August 2010

Requirement要求

No rewrite (一からの書き直しは避けたい)

Reusable (再利用可能)

Simple (シンプル)

Friday, 27 August 2010

Our solution解決方法

http://eiga.com/movie/44107/goods/t142030853/

Friday, 27 August 2010

Separate

Friday, 27 August 2010

Serve file

Friday, 27 August 2010

Bind

Friday, 27 August 2010

AJAX

Friday, 27 August 2010

REST

IMPORTANT : You can synchronise data from client to server by saving before hitting Pusher

Friday, 27 August 2010

Push

Friday, 27 August 2010

Friday, 27 August 2010

Retrospectiveapp

http://screenr.com/NJ0

Friday, 27 August 2010

Retrospectiveapp

Friday, 27 August 2010

Channel & Event

server = new Pusher(Pusher.key, Pusher.channel);

server.bind('note-create', function(note) { generateNote(note);});

post '/notes.json' do content_type 'text/json', :charset => 'utf-8' n = Note.new(params[:note]) n.save Pusher[CHANNEL].trigger('note-create', n.to_json)end

Server side (Ruby)

Client side (Javascript)

We enhanced WebSocket by adding channel and event

Friday, 27 August 2010

Growing With PusherPusher を通して学んだ事

http://www.flickr.com/photos/amy_ng/1692424006/sizes/m/

Friday, 27 August 2010

Growing With PusherPusher を通して学んだ事

Usage Pattern (サーバからクライアントへのデータ通知)

Making Robust & Scalable (スケーラブルにする)

Friday, 27 August 2010

Usage Pattern

3 patterns

Introducing new pattern (新しいパターン)

Friday, 27 August 2010

3 patterns

Friday, 27 August 2010

1: Collaboration

Friday, 27 August 2010

2: Streaming

Friday, 27 August 2010

3:One Day Event

Friday, 27 August 2010

Introducing new pattern: Presence

http://screenr.com/B5O

Friday, 27 August 2010

Introducing new pattern: Presence

Friday, 27 August 2010

Introducing new pattern: Presence

http://github.com/makoto/rubykaigi/tree/presence

class PusherController < ApplicationController def auth response = Pusher[params[:channel_name]].authenticate(params[:socket_id], { :user_id => current_user.id, :user_info => { :name => current_user.username } }) render :json => response else render :text => "Not authorized", :status => '403' end endend

Friday, 27 August 2010

Introducing new pattern: Presence

http://github.com/makoto/rubykaigi/tree/presence

jQuery(function(){ var server = new Pusher('#{Pusher.key}'); var myPresenceChannel = server.subscribe('presence#{pusher_presense_channel}')

myPresenceChannel.bind('pusher:subscription_succeeded', function(member_list){ updatePresence(member_list); })

myPresenceChannel.bind('pusher:member_added', function(member){ updatePresence(myPresenceChannel.members()); })

myPresenceChannel.bind('pusher:member_removed', function(member){ updatePresence(myPresenceChannel.members()); })});

Friday, 27 August 2010

Making Robust & Scalable

Beyond one process (プロセス間通信)

Beyond proxies (プロキシの壁)

Friday, 27 August 2010

Beyond One Processプロセス間通信

@connections = {} # How do you scale beyond one process?EM.run { EM::WebSocket.start(:host => "0.0.0.0",:port =>3001)do|ws| ws.onopen { puts "WebSocket connection open" @connections[ws.id] = ws } ws.onclose { @connections.delete(ws.id)} ws.onmessage { |data| @connections.each do |k, v| v.send(data) unless v.id == ws.id end } end}

Friday, 27 August 2010

Beyond One Processプロセス間通信

API

API

API

WSC CC

WSC CC

WSC CC

Friday, 27 August 2010

Beyond Proxiesプロキシの壁

http://www.infoq.com/articles/Web-Sockets-Proxy-Servers

Friday, 27 August 2010

More Infohttp://blog.pusherapp.com

http://blog.new-bamboo.co.uk

http://video2010.scottishrubyconference.com/

http://www.atmarkit.co.jp (日本語記事書きました)

“We're rubyists living abroad. Any questions?”(08-29 13:30~15出ます)

Friday, 27 August 2010

Thanksご清聴ありがとうございました

http://naun.blog118.fc2.com/

@pusherapp

@makoto_inoue

Friday, 27 August 2010

top related