• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
111214 node conf
 

111214 node conf

on

  • 3,213 views

 

Statistics

Views

Total Views
3,213
Views on SlideShare
2,792
Embed Views
421

Actions

Likes
4
Downloads
11
Comments
0

6 Embeds 421

http://www.cystein.net 376
http://www.railwayjs.jp 18
http://paper.li 15
http://a0.twimg.com 6
http://us-w1.rockmelt.com 4
http://webcache.googleusercontent.com 2

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

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
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

111214 node conf 111214 node conf Presentation Transcript

  • CloudFoundrytransports{[‘websocket’]} 2011/12/14(wed) Node 3
  • • (@komasshu)• html5• WebSocket• Google API Expert (HTML5)• Microsoft Valuable Professional (IE)
  • CloudFoundryWebSocket ...
  • aboutCloud Foundry
  • Cloud Foundry ?• VMWare PaaS https://github.com/cloudfoundry
  • easy demo just push apps$ vmc push hogehoge http://cloudfoundry.com/
  • Heroku• private PaaS•• CloudFoundry PaaS • Active State • AppFog • Joyent
  • Architecture of Cloud Foundryhttp://www.slideshare.net/derekcollison/design-of-cloud-foundry
  • • • Cloud Controller • router • DEA • ...• NATS •
  • hoge.com 3000 app0 (3000) fuga.com 3001 routerhoge.com app1 (3001) DEA register deploy cloud controller push
  • aboutwebsocket
  • WebSocket• HTML5 API/Protocol• Web •
  • • Web(port=80) VPN • SSL-VPN
  • Handshake
  • Handshake
  • HandshakeFrames
  • HTTPGET200GET200GET200
  • HTTPGET200GET200GET200
  • point : UpgradeRequest Header (client => server) GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocketResponse Header (server => client) HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Upgrade HTTP WebSocket
  • HTTP Compatible• VPN • FW, Proxy • HTTP/1.1 • • Web VPN
  • http://www.ericom.com/html5_client_vmware_view.asp http://www.publickey1.jp/blog/11/webhtml5.html
  • WebSocket onCloud Foundry
  • CloudFoundry WebSocket orz• why? • nginx 2 • router HTTP/1.1 rails sinatra nginx router node.js DEA
  • • nginx • zip Access log HTTPS• router • URL routing URL routing unix domain tcp socket socket rails (tcp socket ) 80/443 sinatra nginx router node.js DEA
  • 2 socket.io +transports{‘xhr-polling’}
  • WebSocket nginx • Request HTTP (502) • tcp_proxy Patch •https://github.com/yaoweibin/nginx_tcp_proxy_module
  • nginx.conftcp { upstream vcap_router { server unix:/tmp/router.sock;# server 127.0.0.1:2222;# check interval=3000 rise=2 fall=5 timeout=1000; } tcp_nodelay off; server { listen 80; server_name _; proxy_read_timeout 200000; proxy_send_timeout 200000; proxy_pass vcap_router; }}
  • WebSocket router• HTTP Request/Response HTTP• WebSocket Frames• HTTP
  • dialog of router.rb request Header router request/sec Router on_headers _complete() unix module module node.jsnginx domain TCP socket socket ClientConnection AppConnection on_headers _complete() response Header response latency
  • WebSocketUpgrade: websocketWebsocketConnection router module TCP socket node.js on_headers AppConnection _complete() on_headers unix module _complete() nginx domain socket ClientConnection module WebsocketConne TCP socket node.js ction WS
  • client_connection.rbdef on_headers_complete(headers) .... # [kom] Check connection mode(websocket or not) @is_websocket = (headers[UPGRADE_HEADER] == WEBSOCKET) ? true : false Router.log.info "@is_websocket : #{@is_websocket}" .... if (@is_websocket) host, port = @droplet[:host], @droplet[:port] @bound_app_conn = EM.connect(host, port, WebsocketConnection, self,@headers, @droplet) return end ....end
  • websocket_connection.rbmodule WebsocketConnection def initialize client, header, droplet @client, @header, @droplet = client, header, droplet end def connection_completed send_data(@header) end def receive_data(data) @client.send_data(data) end def terminate end orzend
  • socket.io +transports{‘websocket’} :)
  • moveforward
  • timeline• cloud foundry• websocket• orz• code reading• ←
  • next step• • pull request• brush up
  • problem• vps ... Cent OS, 512MB plan• Cloud Foundry • 1GB memory • Ubuntu10.04.2•
  • router ( ∀ )http://www.slideshare.net/derekcollison/design-of-cloud-foundry
  • • NATS• routing
  • config/routing.yml
  • demo
  • git clonehttps://github.com/KensakuKOMATSU/cf_router
  • $ cd bin$ ./router
  • I love BDD Benkyo-kai Driven Development
  • Thank you!!http://twitter.com/komasshu