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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
York Tsai
May 19, 2013
Programming
3.6k
10
Share
Real-time Web Application with Socket.IO, Node.js, and Redis
From JSDC 2013
York Tsai
May 19, 2013
More Decks by York Tsai
See All by York Tsai
Redis - From LAMP to NOSQL
yorktsai
0
310
Other Decks in Programming
See All in Programming
OSもどきOS
arkw
0
440
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
580
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
110
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
100
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.3k
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
740
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
370
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
230
関係性から理解する"同一性"の型用語たち
pvcresin
2
640
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
190
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
2
410
権限チェックの一貫性を型で守る TypeScript による多層防御
mnch
4
1.1k
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
How to build a perfect <img>
jonoalderson
1
5.6k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
170
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
360
The Cost Of JavaScript in 2023
addyosmani
55
10k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
840
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.6k
The SEO identity crisis: Don't let AI make you average
varn
0
480
Between Models and Reality
mayunak
4
320
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
We Have a Design System, Now What?
morganepeng
55
8.2k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
270
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