CloudFoundrytransports{[‘websocket’]}         2011/12/14(wed)          Node      3
•                             (@komasshu)•             html5•   WebSocket•   Google API Expert (HTML5)•   Microsoft Valuab...
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            ...
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          Up...
HTTP Compatible•           VPN    • FW, Proxy        •         HTTP/1.1    •        •   Web        VPN
http://www.ericom.com/html5_client_vmware_view.asp                                                     http://www.publicke...
WebSocket     onCloud Foundry
CloudFoundry  WebSocket                   orz• why? • nginx                  2 • router      HTTP/1.1                     ...
• nginx • zip      Access log        HTTPS• router • URL routing                                    URL routing           ...
2       socket.io           +transports{‘xhr-polling’}
WebSocket                     nginx    • Request     HTTP                  (502)      •   tcp_proxy Patch      •https://gi...
nginx.conftcp {   upstream vcap_router {     server unix:/tmp/router.sock;# server 127.0.0.1:2222;# check interval=3000 ri...
WebSocket                router•   HTTP Request/Response     HTTP•   WebSocket       Frames•                           HTTP
dialog of router.rb       request  Header                                    router     request/sec         Router        ...
WebSocketUpgrade: websocketWebsocketConnection                                   router                                   ...
client_connection.rbdef on_headers_complete(headers)  ....   # [kom] Check connection mode(websocket or not)   @is_websock...
websocket_connection.rbmodule WebsocketConnection def initialize client, header, droplet  @client, @header, @droplet = cli...
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...
•           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
111214 node conf
111214 node conf
111214 node conf
111214 node conf
111214 node conf
Upcoming SlideShare
Loading in …5
×

111214 node conf

4,697 views

Published on

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

No Downloads
Views
Total views
4,697
On SlideShare
0
From Embeds
0
Number of Embeds
426
Actions
Shares
0
Downloads
18
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • \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

    1. 1. CloudFoundrytransports{[‘websocket’]} 2011/12/14(wed) Node 3
    2. 2. • (@komasshu)• html5• WebSocket• Google API Expert (HTML5)• Microsoft Valuable Professional (IE)
    3. 3. CloudFoundryWebSocket ...
    4. 4. aboutCloud Foundry
    5. 5. Cloud Foundry ?• VMWare PaaS https://github.com/cloudfoundry
    6. 6. easy demo just push apps$ vmc push hogehoge http://cloudfoundry.com/
    7. 7. Heroku• private PaaS•• CloudFoundry PaaS • Active State • AppFog • Joyent
    8. 8. Architecture of Cloud Foundryhttp://www.slideshare.net/derekcollison/design-of-cloud-foundry
    9. 9. • • Cloud Controller • router • DEA • ...• NATS •
    10. 10. hoge.com 3000 app0 (3000) fuga.com 3001 routerhoge.com app1 (3001) DEA register deploy cloud controller push
    11. 11. aboutwebsocket
    12. 12. WebSocket• HTML5 API/Protocol• Web •
    13. 13. • Web(port=80) VPN • SSL-VPN
    14. 14. Handshake
    15. 15. Handshake
    16. 16. HandshakeFrames
    17. 17. HTTPGET200GET200GET200
    18. 18. HTTPGET200GET200GET200
    19. 19. 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
    20. 20. HTTP Compatible• VPN • FW, Proxy • HTTP/1.1 • • Web VPN
    21. 21. http://www.ericom.com/html5_client_vmware_view.asp http://www.publickey1.jp/blog/11/webhtml5.html
    22. 22. WebSocket onCloud Foundry
    23. 23. CloudFoundry WebSocket orz• why? • nginx 2 • router HTTP/1.1 rails sinatra nginx router node.js DEA
    24. 24. • 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
    25. 25. 2 socket.io +transports{‘xhr-polling’}
    26. 26. WebSocket nginx • Request HTTP (502) • tcp_proxy Patch •https://github.com/yaoweibin/nginx_tcp_proxy_module
    27. 27. 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; }}
    28. 28. WebSocket router• HTTP Request/Response HTTP• WebSocket Frames• HTTP
    29. 29. 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
    30. 30. 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
    31. 31. 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
    32. 32. 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
    33. 33. socket.io +transports{‘websocket’} :)
    34. 34. moveforward
    35. 35. timeline• cloud foundry• websocket• orz• code reading• ←
    36. 36. next step• • pull request• brush up
    37. 37. problem• vps ... Cent OS, 512MB plan• Cloud Foundry • 1GB memory • Ubuntu10.04.2•
    38. 38. router ( ∀ )http://www.slideshare.net/derekcollison/design-of-cloud-foundry
    39. 39. • NATS• routing
    40. 40. config/routing.yml
    41. 41. demo
    42. 42. git clonehttps://github.com/KensakuKOMATSU/cf_router
    43. 43. $ cd bin$ ./router
    44. 44. I love BDD Benkyo-kai Driven Development
    45. 45. Thank you!!http://twitter.com/komasshu

    ×