ActionCable, WebSocket and Scalability

B338e877fffff7a61d90a799c081c85b?s=47 Daniel Lv
October 11, 2015

ActionCable, WebSocket and Scalability

以 Rails 5.0 即将发布的 ActionCable 作为切入点,给大家介绍一下事实 WebSocket 的内部实现,以及在生产环境下如何去正确的水平扩展 WebSocket 服务。

B338e877fffff7a61d90a799c081c85b?s=128

Daniel Lv

October 11, 2015
Tweet

Transcript

  1. None
  2. ActionCable, WebSocket and Scalability ݾࢵਘ

  3. ᛔ౯Օᕨ • Ruby China ᐒ܄ᓕቘާ • RubyConf China य़տᕟᕢᘏ •

    Teahour.FM Ԇඎ • ংᇁ @lgn21st lgn21st@gmail.com
  4. None
  5. ౯ጱੜᆽঅ

  6. ᬯฎӞӻӸᘾጱದ๞य़տ

  7. ಅզ౯ᥝ्กᛔ૩ጱᒈ࣋

  8. ٿฎᚙᐶ࣋ว᧨ದ๞᮷ฎᘓၞ࿇

  9. What’s New in Rails 5?

  10. Rails API

  11. Turbolinks 3

  12. ActionCable

  13. Real-time Web

  14. Real-time Web ԏ᪠ • Polling • Long Polling / Comet

    • Server-Sent Event (SSE) • XMPP҅Flash҅etc…
  15. Polling

  16. message_bus

  17. Server-Sent Event

  18. Server-Sent Event

  19. Long Polling / Comet

  20. WebSocket Protocol • W3C • පሲ

  21. handshake over HTTP

  22. GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade HTTP/1.1

    101 Switching Protocols Upgrade: websocket Connection: Upgrade
  23. පሲ҅පሲ҅ᬮฎ™පሲ

  24. Ruby and WebSockets • Third-party Service / pusher.com • Stand-alone

    server / Slanger • EventMachine + em-websocket • Faye
  25. @igrigorik Author of em-websocket

  26. None
  27. faye-websocket • websocket-driver • eventmachine

  28. em-websocket V.S. websocket-driver

  29. ActionCable

  30. "If you can make WebSockets even less work than polling,

    why wouldn't you do it?” @DHH
  31. Seamlessly integration with Rails

  32. None
  33. actioncable-examples

  34. ActionCable Server • faye-websocket • Redis / em-hiredis • Celluloid

  35. Under the hood • Authorization (Signed Cookie) • API •

    Connection • Channel • Broadcast • PubSub
  36. ActionCable Client Library • Create Consumer • Subscription • ConnectionMonitor

  37. EventMachine or Celluloid

  38. EventMachine ጱੴᴴ • ಅํጱ୑ྍձۓ᮷ׁᩢ EM.reactor_running • դᎱ஗ሾ્ॺ҅ᵙ᧛҅ᵙٟ҅ᵙ᧣ᦶ • ྋᏟጱֵአ Defer

    ੒᨝
  39. Celluloid

  40. Tony Arcieri Author of Celluloid

  41. Celluloid • Created at 2011 • Actor Model • Ecosystem

    • Celluloid::IO • Reel::IO • DCell • Sidekiq
  42. Threading is Hard

  43. Scalability

  44. ࣋ว

  45. None
  46. Single Server • TCP/IP parameters • Maximum Number Of FD

    • Memory / Network • Concurrent Model
  47. One More Pit

  48. None
  49. ೗ᘷଠޞ • Rubyist / ڹᒒ / ᑏۖᒒ / HR •

    ᓌܲ᧗ݎ hr@baoquan.com
  50. ᨀᨀय़ਹ

  51. ဌࠨଗᨵ ᥝӧߕڦ Q&A ԧމҘ