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

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

From JSDC 2013

5be3ce1e4751250c7276966dbe50611d?s=128

York Tsai

May 19, 2013
Tweet

Transcript

  1. 4.
  2. 5.

    You may Have Heard About • Forever Iframe • XMLHttpRequest

    Long Polling • Cometd • Websocket • http://en.wikipedia.org/wiki/Comet_(programming ) • TL;DR
  3. 6.

    Socket.IO • Cross browser (including IE 6) • Real-time and

    bi-directional persistent connection (WebSocket) • Very simple to use • Javascript!
  4. 9.
  5. 12.
  6. 17.

    Data Persistence • Need a persistence layer • Get data

    from the persistence layer whenever a new connection established
  7. 21.

    Redis • Super-fast in-memory data structure server • Pub/Sub •

    Rich client libraries • Zero install and easy to operate
  8. 25.

    Redis-backed Pub/Sub • Two clients required: one for pub, one

    for sub • Use one channel, add metadata to your message
  9. 28.
  10. 33.

    Authentication • Cookie & Session • Cookie does not cross

    domain, use SSL + Access Token instead
  11. 36.

    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
  12. 38.

    Configurations • store (default: MemoryStore, single process only) • transports

    (default: websocket, htmlfile, xhr- polling, jsonp-polling) • authorization (default: false)
  13. 40.

    Thank You! The slide is also the live demo itself.

    Please check the following repo! https://github.com/yorktsai/jsdc2013