SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
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 ...
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
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, xhrpolling, 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

Contenu connexe

Tendances

Integração do Zabbix com AWS EC2 Auto Scalling - 1º ZABBIX MEETUP DO INTERIOR-SP
Integração do Zabbix com AWS EC2 Auto Scalling - 1º ZABBIX MEETUP DO INTERIOR-SPIntegração do Zabbix com AWS EC2 Auto Scalling - 1º ZABBIX MEETUP DO INTERIOR-SP
Integração do Zabbix com AWS EC2 Auto Scalling - 1º ZABBIX MEETUP DO INTERIOR-SP
André Déo
 
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
흥배 최
 

Tendances (20)

파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥
파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥
파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥
 
Welcome to JanusCon! -- Past, Present and Future of Janus
Welcome to JanusCon! -- Past, Present and Future of JanusWelcome to JanusCon! -- Past, Present and Future of Janus
Welcome to JanusCon! -- Past, Present and Future of Janus
 
Session,Cookies and Authentication
Session,Cookies and AuthenticationSession,Cookies and Authentication
Session,Cookies and Authentication
 
Meeting Scheduler using android and web application (UML Diagrams)
Meeting Scheduler using android and web application (UML Diagrams)Meeting Scheduler using android and web application (UML Diagrams)
Meeting Scheduler using android and web application (UML Diagrams)
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
 
Puppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIPuppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node API
 
Bug bounty recon.pdf
Bug bounty recon.pdfBug bounty recon.pdf
Bug bounty recon.pdf
 
Watir
WatirWatir
Watir
 
Security Testing with Zap
Security Testing with ZapSecurity Testing with Zap
Security Testing with Zap
 
Integração do Zabbix com AWS EC2 Auto Scalling - 1º ZABBIX MEETUP DO INTERIOR-SP
Integração do Zabbix com AWS EC2 Auto Scalling - 1º ZABBIX MEETUP DO INTERIOR-SPIntegração do Zabbix com AWS EC2 Auto Scalling - 1º ZABBIX MEETUP DO INTERIOR-SP
Integração do Zabbix com AWS EC2 Auto Scalling - 1º ZABBIX MEETUP DO INTERIOR-SP
 
HowYourAPIBeMyAPI
HowYourAPIBeMyAPIHowYourAPIBeMyAPI
HowYourAPIBeMyAPI
 
The WebKit project
The WebKit projectThe WebKit project
The WebKit project
 
Full Stack Web Development.pptx
Full Stack Web Development.pptxFull Stack Web Development.pptx
Full Stack Web Development.pptx
 
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webappsMikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
 
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
 
online voting system
online voting systemonline voting system
online voting system
 
Learn to pen-test with OWASP ZAP
Learn to pen-test with OWASP ZAPLearn to pen-test with OWASP ZAP
Learn to pen-test with OWASP ZAP
 
Атаки на видеоконвертеры: год спустя
Атаки на видеоконвертеры: год спустяАтаки на видеоконвертеры: год спустя
Атаки на видеоконвертеры: год спустя
 
FMK2017 - Eine Bilddatenbank mit FileMaker erstellen by Karsten Risseeuw
FMK2017 - Eine Bilddatenbank mit FileMaker erstellen by Karsten RisseeuwFMK2017 - Eine Bilddatenbank mit FileMaker erstellen by Karsten Risseeuw
FMK2017 - Eine Bilddatenbank mit FileMaker erstellen by Karsten Risseeuw
 
Introduction to Modern Identity with Auth0's Developer
 Introduction to Modern Identity with Auth0's Developer Introduction to Modern Identity with Auth0's Developer
Introduction to Modern Identity with Auth0's Developer
 

En vedette

Building notification system in NodeJS + Redis
Building notification system in NodeJS + RedisBuilding notification system in NodeJS + Redis
Building notification system in NodeJS + Redis
Le Duc
 
Notifications - Building a transparent system
Notifications - Building a transparent systemNotifications - Building a transparent system
Notifications - Building a transparent system
João Lopes
 

En vedette (20)

Building notification system in NodeJS + Redis
Building notification system in NodeJS + RedisBuilding notification system in NodeJS + Redis
Building notification system in NodeJS + Redis
 
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, InuitReal Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
 
Going real time with Socket.io
Going real time with Socket.ioGoing real time with Socket.io
Going real time with Socket.io
 
Websocket + Redis pubsub
Websocket + Redis pubsubWebsocket + Redis pubsub
Websocket + Redis pubsub
 
Real Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.ioReal Time Communication using Node.js and Socket.io
Real Time Communication using Node.js and Socket.io
 
Going realtime with Socket.IO
Going realtime with Socket.IOGoing realtime with Socket.IO
Going realtime with Socket.IO
 
Socket.io (part 1)
Socket.io (part 1)Socket.io (part 1)
Socket.io (part 1)
 
Redis : Database, cache, pub/sub and more at Jelly button games
Redis : Database, cache, pub/sub and more at Jelly button gamesRedis : Database, cache, pub/sub and more at Jelly button games
Redis : Database, cache, pub/sub and more at Jelly button games
 
laravel websocket(use redis pubsub) [Laravel meetup tokyo]
laravel websocket(use redis pubsub) [Laravel meetup tokyo]laravel websocket(use redis pubsub) [Laravel meetup tokyo]
laravel websocket(use redis pubsub) [Laravel meetup tokyo]
 
Transforming WebSockets
Transforming WebSocketsTransforming WebSockets
Transforming WebSockets
 
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
 
Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?Real time web: is there a life without socket.io and node.js?
Real time web: is there a life without socket.io and node.js?
 
The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in Django
 
High-Volume Data Collection and Real Time Analytics Using Redis
High-Volume Data Collection and Real Time Analytics Using RedisHigh-Volume Data Collection and Real Time Analytics Using Redis
High-Volume Data Collection and Real Time Analytics Using Redis
 
Node.js + Websocket 삽질기
Node.js + Websocket 삽질기Node.js + Websocket 삽질기
Node.js + Websocket 삽질기
 
Angular mixed Sails, we are in MEAN stack
Angular mixed Sails, we are in MEAN stackAngular mixed Sails, we are in MEAN stack
Angular mixed Sails, we are in MEAN stack
 
Socket.io under the hood
Socket.io under the hoodSocket.io under the hood
Socket.io under the hood
 
Notifications - Building a transparent system
Notifications - Building a transparent systemNotifications - Building a transparent system
Notifications - Building a transparent system
 
SWT Tech Sharing: Node.js + Redis
SWT Tech Sharing: Node.js + RedisSWT Tech Sharing: Node.js + Redis
SWT Tech Sharing: Node.js + Redis
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
 

Similaire à Real-time Web Application with Socket.IO, Node.js, and Redis

Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Corey Clark, Ph.D.
 
HTML5 New Features and Resources
HTML5 New Features and ResourcesHTML5 New Features and Resources
HTML5 New Features and Resources
Ron Reiter
 

Similaire à Real-time Web Application with Socket.IO, Node.js, and Redis (20)

Java script everywhere
Java script everywhereJava script everywhere
Java script everywhere
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Servers? Where we're going we don't need servers.
Servers? Where we're going we don't need servers.Servers? Where we're going we don't need servers.
Servers? Where we're going we don't need servers.
 
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
 
HTML5 New Features and Resources
HTML5 New Features and ResourcesHTML5 New Features and Resources
HTML5 New Features and Resources
 
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
 
IoT-javascript-2019-fosdem
IoT-javascript-2019-fosdemIoT-javascript-2019-fosdem
IoT-javascript-2019-fosdem
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
 
Using JavaScript to write Native Mobile Applications
Using JavaScript to write Native Mobile ApplicationsUsing JavaScript to write Native Mobile Applications
Using JavaScript to write Native Mobile Applications
 
webthing-iotjs-tizenrt-cdl2018-20181117rzr
webthing-iotjs-tizenrt-cdl2018-20181117rzrwebthing-iotjs-tizenrt-cdl2018-20181117rzr
webthing-iotjs-tizenrt-cdl2018-20181117rzr
 
CON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project NashornCON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project Nashorn
 
Node
NodeNode
Node
 
Mastering the pipeline
Mastering the pipelineMastering the pipeline
Mastering the pipeline
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
 
The Next Leap in JavaScript Performance
The Next Leap in JavaScript PerformanceThe Next Leap in JavaScript Performance
The Next Leap in JavaScript Performance
 
Javascript as a target language - GWT KickOff - Part 2/2
Javascript as a target language - GWT KickOff - Part 2/2Javascript as a target language - GWT KickOff - Part 2/2
Javascript as a target language - GWT KickOff - Part 2/2
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Building desktop apps in java script with Electron
Building desktop apps in java script with ElectronBuilding desktop apps in java script with Electron
Building desktop apps in java script with Electron
 
Wt
WtWt
Wt
 
Web Leaps Forward
Web Leaps ForwardWeb Leaps Forward
Web Leaps Forward
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Real-time Web Application with Socket.IO, Node.js, and Redis