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
Real-time Web Application with Socket.IO, Node....
Search
York Tsai
May 19, 2013
Programming
10
3.6k
Real-time Web Application with Socket.IO, Node.js, and Redis
From JSDC 2013
York Tsai
May 19, 2013
Tweet
Share
More Decks by York Tsai
See All by York Tsai
Redis - From LAMP to NOSQL
yorktsai
0
300
Other Decks in Programming
See All in Programming
Pythonに漸進的に型をつける
nealle
1
150
One Enishi After Another
snoozer05
PRO
0
180
品質ワークショップをやってみた
nealle
0
930
AI Agent 時代的開發者生存指南
eddie
4
2.3k
テーブル定義書の構造化抽出して、生成AIでDWH分析を試してみた / devio2025tokyo
kasacchiful
0
370
KoogではじめるAIエージェント開発
hiroaki404
1
290
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
6k
Towards Transactional Buffering of CDC Events @ Flink Forward 2025 Barcelona Spain
hpgrahsl
0
120
SidekiqでAIに商品説明を生成させてみた
akinko_0915
0
110
Register is more than clipboard
satorunooshie
1
370
お前も Gemini CLI extensions を作らないか?
satohjohn
0
100
Reactive Thinking with Signals and the Resource API
manfredsteyer
PRO
0
120
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Music & Morning Musume
bryan
46
6.9k
How to train your dragon (web standard)
notwaldorf
97
6.3k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Become a Pro
speakerdeck
PRO
29
5.6k
Done Done
chrislema
186
16k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.2k
Designing for Performance
lara
610
69k
4 Signs Your Business is Dying
shpigford
186
22k
Transcript
Real-time Web Application with Socket.IO, Node.js, and Redis York Tsai,
JSDC 2013
Who is York • http://www.linkedin.com/pub/york-tsai/13/bb/8a8 • https://twitter.com/yorktsai • https://www.facebook.com/yorktsai •
VP Engineering @ EZTABLE
Never Live Demo! • http://jsdc.york.tw/ • I hope this work
on my (and yours) computer ...
None
You may Have Heard About • Forever Iframe • XMLHttpRequest
Long Polling • Cometd • Websocket • http://en.wikipedia.org/wiki/Comet_(programming ) • TL;DR
Socket.IO • Cross browser (including IE 6) • Real-time and
bi-directional persistent connection (WebSocket) • Very simple to use • Javascript!
Start a Server
Sending and Receiving Events
None
Select Receivers for Events
Broadcasting
Rooms
Single Target
Multiple Applications?
Namespacing
How About New Connections?
Data Persistence • Need a persistence layer • Get data
from the persistence layer whenever a new connection established
Integration I have component X,Y,Z want to send/receive data from
user's browser
Pub/Sub or Message Queue Messaging system usually supports both
Pub/Sub Digram from Python's Website
Redis • Super-fast in-memory data structure server • Pub/Sub •
Rich client libraries • Zero install and easy to operate
3 Commands • SUBSCRIBE channel • UNSUBSCRIBE channel • PUBLISH
channel message
In addition... • Connect multiple node.js server to one redis
channel • Scalability!
Two Connections per Server
Redis-backed Pub/Sub • Two clients required: one for pub, one
for sub • Use one channel, add metadata to your message
Redis-backed Pub/Sub
Frequently Asked Questions
SSL? Yes!
SSL Server
SSL Client
Cross domain? Yes! (If use WebSocket or JSONP)
Authentication?
Authentication • Cookie & Session • Cookie does not cross
domain, use SSL + Access Token instead
Load Balancing? Yes! (If use Nginx >= 1.3.13)
Sample Nginx Configuration
Load Balancing using ELB • ELB (Elastic Load Balancer)'s HTTP(S)
proxy does not understand websocket requests • Use TCP/SSL, instead of HTTP/HTTPS • No session stickyness • No X-Forwarded-For header
Scalability • Single thread • 2500~3500 connections per process •
As many processes as you want
Configurations • store (default: MemoryStore, single process only) • transports
(default: websocket, htmlfile, xhr- polling, jsonp-polling) • authorization (default: false)
Configurations - transports
Thank You! The slide is also the live demo itself.
Please check the following repo! https://github.com/yorktsai/jsdc2013