Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ActionCable, WebSocket and Scalability
Search
Daniel Lv
October 11, 2015
Technology
3
610
ActionCable, WebSocket and Scalability
以 Rails 5.0 即将发布的 ActionCable 作为切入点,给大家介绍一下事实 WebSocket 的内部实现,以及在生产环境下如何去正确的水平扩展 WebSocket 服务。
Daniel Lv
October 11, 2015
Tweet
Share
More Decks by Daniel Lv
See All by Daniel Lv
Matz - Be a language designer
lgn21st
9
1.1k
Koz - 听我们的?
lgn21st
2
380
Other Decks in Technology
See All in Technology
CI/CDとタスク共有で加速するVibe Coding
tnbe21
0
180
Cloud Native Scalability for Internal Developer Platforms
hhiroshell
2
460
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
17k
Tenstorrent HW/SW 概要説明
tenstorrent_japan
0
400
Rubyで作る論理回路シミュレータの設計の話 - Kashiwa.rb #12
kozy4324
1
310
“プロダクトを好きになれるか“も QAエンジニア転職の大事な判断基準だと思ったの
tomodakengo
0
140
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
5
38k
vLLM meetup Tokyo
jpishikawa
1
240
本部長の代わりに提案書レビュー! KDDI営業が毎日使うAIエージェント「A-BOSS」開発秘話
minorun365
PRO
14
1.8k
開発効率と信頼性を両立する Ubieのプラットフォームエンジニアリング
teru0x1
0
140
自分を理解するAI時代の準備 〜マイプロフィールMCPの実装〜
edo_m18
0
110
Securing your Lambda 101
chillzprezi
0
290
Featured
See All Featured
BBQ
matthewcrist
89
9.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.7k
Designing for humans not robots
tammielis
253
25k
We Have a Design System, Now What?
morganepeng
52
7.6k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Designing for Performance
lara
609
69k
GraphQLとの向き合い方2022年版
quramy
46
14k
Faster Mobile Websites
deanohume
307
31k
Why Our Code Smells
bkeepers
PRO
337
57k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
The World Runs on Bad Software
bkeepers
PRO
68
11k
Transcript
None
ActionCable, WebSocket and Scalability ݾࢵਘ
ᛔ౯Օᕨ • Ruby China ᐒ܄ᓕቘާ • RubyConf China य़տᕟᕢᘏ •
Teahour.FM Ԇඎ • ংᇁ @lgn21st
[email protected]
None
౯ጱੜᆽঅ
ᬯฎӞӻӸᘾጱದय़տ
ಅզ౯ᥝ्กᛔ૩ጱᒈ࣋
ٿฎᚙᐶ࣋ว᧨ದ᮷ฎᘓၞ࿇
What’s New in Rails 5?
Rails API
Turbolinks 3
ActionCable
Real-time Web
Real-time Web ԏ᪠ • Polling • Long Polling / Comet
• Server-Sent Event (SSE) • XMPP҅Flash҅etc…
Polling
message_bus
Server-Sent Event
Server-Sent Event
Long Polling / Comet
WebSocket Protocol • W3C • පሲ
handshake over HTTP
GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade HTTP/1.1
101 Switching Protocols Upgrade: websocket Connection: Upgrade
පሲ҅පሲ҅ᬮฎ™පሲ
Ruby and WebSockets • Third-party Service / pusher.com • Stand-alone
server / Slanger • EventMachine + em-websocket • Faye
@igrigorik Author of em-websocket
None
faye-websocket • websocket-driver • eventmachine
em-websocket V.S. websocket-driver
ActionCable
"If you can make WebSockets even less work than polling,
why wouldn't you do it?” @DHH
Seamlessly integration with Rails
None
actioncable-examples
ActionCable Server • faye-websocket • Redis / em-hiredis • Celluloid
Under the hood • Authorization (Signed Cookie) • API •
Connection • Channel • Broadcast • PubSub
ActionCable Client Library • Create Consumer • Subscription • ConnectionMonitor
EventMachine or Celluloid
EventMachine ጱੴᴴ • ಅํጱྍձۓ᮷ׁᩢ EM.reactor_running • դᎱሾ્ॺ҅ᵙ҅ᵙٟ҅ᵙ᧣ᦶ • ྋᏟጱֵአ Defer
Celluloid
Tony Arcieri Author of Celluloid
Celluloid • Created at 2011 • Actor Model • Ecosystem
• Celluloid::IO • Reel::IO • DCell • Sidekiq
Threading is Hard
Scalability
࣋ว
None
Single Server • TCP/IP parameters • Maximum Number Of FD
• Memory / Network • Concurrent Model
One More Pit
None
ᘷଠޞ • Rubyist / ڹᒒ / ᑏۖᒒ / HR •
ᓌܲ᧗ݎ
[email protected]
ᨀᨀय़ਹ
ဌࠨଗᨵ ᥝӧߕڦ Q&A ԧމҘ