Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building real-time applications with Node.js

sbarysiuk
November 02, 2012

Building real-time applications with Node.js

Real-time applications like chats, large-scale games, collaborative editing require a new way to communicate with server and a different approach designing them. Node.js is a platform built on Chrome's JavaScript runtime for easy building fast, scalable real-time network applications.
This presentation walks you through the process of building a real-time app with Node.js and Socket.io.

sbarysiuk

November 02, 2012
Tweet

More Decks by sbarysiuk

Other Decks in Programming

Transcript

  1. About me • CTO and co-founder at Propellerz • founded

    a few startups - Quote Roller, NotiNote • a big JS fan - client and server side
  2. What is Node.js? • JavaScript programming environment • Uses V8

    runtime (Chrome’s JS runtime) • Event driven, single threaded • Non blocking I/O
  3. How to start with Node.js? • Install Node from nodejs.org

    (Mac, Linux Windows) • Install NPM from npmjs.org • Run your app as
  4. Real-time web In real-time world, there is no polling. Instead,

    there are subscriptions. Changes don't need to be pulled because they're pushed instead.
  5. Polling & Comet Using different approaches to implement streaming: Iframe

    Streaming, Flash Streaming, XHR Streaming, JSONP Polling • Works in old browsers • Inefficient • Hard to scale + - -
  6. Web Sockets • Full-duplex communication over a TCP socket •

    Lightweight: no TCP handshake, no HTTP headers overhead • Only new modern browsers - + +
  7. Socket.io • WebSockets transport • Fallback transports for old browsers

    (Flash Sockets, XHR Long Polling, JSON Pooling) • Heartbeats, timeouts and disconnection support + + +
  8. Demo app: explained Client Server connection ready * joined move

    * move move damage * damage damage disconnect * disconnected ...
  9. Deploying the app... • Your own server • PaaS: appfog.com,

    cloudfoundry.com, heroku.com, etc. • nodejitsu.com, supports web sockets