SlideShare uma empresa Scribd logo
1 de 43
Baixar para ler offline
REAL-TIME WEB APPS
Sepehr Rasouli
OVERVIEW
1.Introduction & Applications
2.Low level real-time implementation
3.Real-time Technologies
4.Sample code
5.Demo(HTTP polling, HTTP streaming,
WebSocket)
WHAT ARE REAL-TIME WEB APPS?
• Allows users to receive information as soon
as it is published
• Bi-directional communication between
clients & server
• Both pull and push based systems
EXAMPLES & APPLICATIONS
• Gmail
• Facebook
• Twitter
• Chat Services
• Online Gaming
• Notification and signaling
• Shows live data
• Easy collaboration
Notification and signaling
Activity Streams
DataVisualization
Online Multiplayer Games
METHODS(HTTP)
•One-way
•Request/Response
•Stateless
REAL-TIME “HACKS”
•Long polling
•HTTP Streaming
•AJAX (XMLHTTPRequest &
InnerHTML)
AJAX REQUEST
• Window.open()
• HTTP Request browser will stop or hang for the server
response
• Xmlhttp.open()
• Ajax request is Async, java script does not have to wait
for the server response, so it can execute other scripts
and respond to user events while waiting for server
response
CONS OF “HACKS”
•http web server timeouts
•Too many connections
•Too much overhead
•Only a workaround and not a
native solution
WEBSOCKET PROTOCOL
•Websocket is a Full Duplex Web
Protocol
•Two-way messaging over single
connection
•Low over-head
WEBSOCKET PERFORMANCE
• Each HTTP Request/Response (header + body) have
minimum of 871 Bytes over head
• WebSocket frames has 2 Bytes of over head
• 1000 HTTP Clients polling per second = 6.6Mbps
Network throughput
• 1000WebSocket Clients receiving messages per second =
0.015Mbps Network throughput
WEBSOCKET PERFORMANCE VS
POLLING
REAL-TIME TECHNOLOGIES
• Self hosted (PaaS)
Why use an existing solution?
• Support/Community
• Maintenance
• Future features
• Scaling
• Eg:
Pusher, PubNub, Firebase, realtime.co & deepstreamHub
Self Hosted (Tightly Coupled)
Self Hosted (Loosely Coupled)
DEV LIBRARIES
• Websocket & Messaging libraries
• Publish / Subscribe libraries
• Data-Sync
• Hybrids
WEBSOCKET & MESSAGING LIBRARIES
FEATURES
• heartbeats / keep alive calls
these are tiny messages that are send on pre-defined intervals.They
make sure that the other side is still responsive and prevent certain
network constructs like proxies or firewalls from cutting your
connection due to inactivity.
• reconnecting
if your connection drops, you want it to be re-established. Some
libraries also queue messages while the connection is down and
resend them once it becomes available again.
WEBSOCKET & MESSAGING LIBRARIES
FEATURES
• http fallback
if WebSockets are not available, some libraries fall back
to http long polling and other techniques to mimic bi-
directional communication (collectively known as
"comet"). Depending on your target audience this might
not be a necessity, but is still a good choice if your app
needs to be available within large corporate
infrastructures.
WEBSOCKET LIBRARIES
• engine.io
Engine.io is the transport layer that powers socket.io, but can
also be used as a standalone library. It incorporates a few
unusual design choices, such as starting with http long-polling to
ensure immediate connectivity and only upgrade the connection
to websocket a bit later.
• WS
A solid, barebone WebSocket server for node.js Used by
engine.io
• SockJS
A fast JavaScript / Node.js abstraction layer for websockets,
supporting a number of fallback techniques
WEBSOCKET LIBRARIES
• Tornado
Tornado is a general purpose networking library for
Python, offeringWebsocket abstractions and fallbacks.
• web-socket-js
Flash based websocket implementation
• libwebsocket
Really fast websocket implementation in low level C.
• Fleck
Fleck is a WebSocket implementation in C#
WEBSOCKET LIBRARIES
• Atmosphere
Atmosphere is a general websocket abstraction layer for
JVM compatible languages. It's focused to run on Java and
J2EE application servers and comes with an ecosystem of
extension points to connect it to caches like Redis or
Hazelcast.
• Java Web Socket
Exactly what the name suggests
WEBSOCKET LIBRARIES
• Mojolicious
A websocket implementation with fallbacks for Perl
• SignalR
WebSocket abstraction for .NET
• SuperWebSocket
TCP/Websocket library for .NET
• Plezy
WebSocket abstraction for Ruby
PUBLISH / SUBSCRIBE
• Real-time messaging
• Many clients subscribe to a topic (sometimes also
called an event, namespace or channel) and other
clients publish messages on that topic.This is a
simple and scalable pattern for many-to-many
communication.
PUBLISH / SUBSCRIBE LIBRARIES
• socket.io
Definitely the most popular. Socket.io is a Node.js library that comes
with clients in many languages. It offers direct messaging and pub-sub
based on rooms (think chat-rooms) with the ability to distribute load
across multiple nodes using a Redis server in the background.
• socket cluster
A pub-sub framework built in Node.js that focuses on load-balancing
connections across a larger cluster of processes.
• Centrifugo
A backend agnostic pub-sub system written in Go
PUBLISH / SUBSCRIBE LIBRARIES
• Faye
One of the first pub/sub systems around. Faye offers servers in both
Ruby and Node and implements the Bayeux Protocol, designed 2007
by the Dojo foundation. Similar to socket.io, Faye relies on Redis
pub/sub to scale across multiple nodes. It does however lack support
for Redis clusters which limits its scalability to a single Redis instance.
• Firehose.io
A simple, Ruby based pub-sub system with integration points for
Backbone and Ember.
• Phoenix Framework
Phoenix is a whole web-app framework for Erlang, but with a focus on
pub/sub via channels.
DATA-SYNC
• Why not Pub/Sub?
• User A changes some data and hits save.The data is send via ajax to a
server and stored in a database. The client now publishes an event,
e.g. Data-update/<some-id> .
Other clients receive this event, make an ajax request to the server
and download the updated data.
• Data-sync models your data as observable objects or tree-structures
that can be manipulated by clients and servers.
Any change to the data is immediately synchronized across all
connected clients.
• This significantly reduces request-overhead, makes applications faster
and development simpler.
DATA-SYNC LIBRARIES
• Horizon
RethinkDB’s Horizon - a Node.js server and associated JavaScript
client library that sits on top of RethinkDB and exposes its database
and realtime querying capabilities to browser apps.
Horizon supports authentication via openAuth and JSON webtoken
and access control viaTOML configured permissions for user groups
• FeatherJS
FeatherJS is a RESTful CRUD framework for Node build on top of
express.js that sends out events via a socket.io connection whenever
an object is created, updated or deleted, allowing clients to react
accordingly.
REMOTE PROCEDURE CALL (RPC) / REMOTE
METHOD INVOCATION (RMI)
not strictly a realtime concept, but more the
classical REST/HTTP request/response workflow,
mapped onto a bi-directional connection.
RPC allows you to call methods on a remote server
and process their response.This can be a powerful
concept in itself, but it becomes even more
powerful when used in conjunction with other
realtime concepts like pub/sub or data-sync
HYBRIDS
• In a voting system you might want to send a user’s vote as
a remote method invocation - which increment the
number of votes on a data-sync object as well as block the
voting user from voting more than once.
• For multiplayer games it can make sense to rely on simple
pub-sub messaging to update player positions whilst using
data-sync to keep track of scores.
HYBRIDS
• Deepstream.io
Deepstream.io is a realtime server that combines data-sync with
pub/sub and request response. It offers an open ecosystem of
connectors for databases, caches and messaging systems. Its
unobtrusive client plays well with any M*C framework and comes with
plugins for React, Polymer and other libraries.
• Meteor
Meteor is a full stack framework for realtime apps, featuring data-sync,
pub/sub, RPCs, realtime search and a host of other features. It offers a
highly structured and opinionated way to set up and connect servers
and databases, build clients and test and deploy applications. It comes
with its own, self-contained ecosystem, including a proprietary
(potentially soon to be deprecated?) package manager and originally its
own client side templating library.
HYBRIDS
• Autobahn
Autobahn offers Pub/Sub and RPC. It's a server implementing the
WAMP (Web Application Messaging Protocol) spec and offers a
selection of clients for JS, Python,Android and C++.
• CometD
CometD has been one of the first entries in the realtime space. It
combines pub/sub with rpcs and supports browser connectivity via a
stack of comet techniques.
LIBS BASED ON LANGUAGE
• Java: Netty, Jetty
• JavaScript (Node.JS): Faye, Socket.IO (Engine.IO), Primus.io
• .NET (C#): SignalR, XSockets
• Python: Lots of options built on Tornado
• PHP: ReactPHP, Ratchet
• Ruby: Faye
RESOURCES
• https://www.leggetter.co.uk/
• https://deepstreamhub.com
• www.Wikipedia.org

Mais conteúdo relacionado

Mais procurados

Getting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsGetting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent Events
Arun Gupta
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMix
Bruce Snyder
 
Web servers – features, installation and configuration
Web servers – features, installation and configurationWeb servers – features, installation and configuration
Web servers – features, installation and configuration
webhostingguy
 
Implementing Advanced Caching and Replication Techniques in ...
Implementing Advanced Caching and Replication Techniques in ...Implementing Advanced Caching and Replication Techniques in ...
Implementing Advanced Caching and Replication Techniques in ...
webhostingguy
 
Developing Distributed Web Applications, Where does REST fit in?
Developing Distributed Web Applications, Where does REST fit in?Developing Distributed Web Applications, Where does REST fit in?
Developing Distributed Web Applications, Where does REST fit in?
Srinath Perera
 

Mais procurados (20)

RESTful APIs
RESTful APIsRESTful APIs
RESTful APIs
 
Web Servers (ppt)
Web Servers (ppt)Web Servers (ppt)
Web Servers (ppt)
 
OAuth
OAuthOAuth
OAuth
 
Getting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent EventsGetting Started with WebSockets and Server-Sent Events
Getting Started with WebSockets and Server-Sent Events
 
Apache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMixApache ActiveMQ and Apache ServiceMix
Apache ActiveMQ and Apache ServiceMix
 
Web server
Web serverWeb server
Web server
 
Coherence sig-nfr-web-tier-scaling-using-coherence-web
Coherence sig-nfr-web-tier-scaling-using-coherence-webCoherence sig-nfr-web-tier-scaling-using-coherence-web
Coherence sig-nfr-web-tier-scaling-using-coherence-web
 
Web servers
Web serversWeb servers
Web servers
 
web server
web serverweb server
web server
 
Web Server And Database Server
Web Server And Database ServerWeb Server And Database Server
Web Server And Database Server
 
Web Server - Internet Applications
Web Server - Internet ApplicationsWeb Server - Internet Applications
Web Server - Internet Applications
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafka
 
Apache Kafka Introduction
Apache Kafka IntroductionApache Kafka Introduction
Apache Kafka Introduction
 
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
 
Kaazing
KaazingKaazing
Kaazing
 
Web servers – features, installation and configuration
Web servers – features, installation and configurationWeb servers – features, installation and configuration
Web servers – features, installation and configuration
 
Apache kafka introduction
Apache kafka introductionApache kafka introduction
Apache kafka introduction
 
Kafka as Message Broker
Kafka as Message BrokerKafka as Message Broker
Kafka as Message Broker
 
Implementing Advanced Caching and Replication Techniques in ...
Implementing Advanced Caching and Replication Techniques in ...Implementing Advanced Caching and Replication Techniques in ...
Implementing Advanced Caching and Replication Techniques in ...
 
Developing Distributed Web Applications, Where does REST fit in?
Developing Distributed Web Applications, Where does REST fit in?Developing Distributed Web Applications, Where does REST fit in?
Developing Distributed Web Applications, Where does REST fit in?
 

Semelhante a Real time web apps

Big data conference europe real-time streaming in any and all clouds, hybri...
Big data conference europe   real-time streaming in any and all clouds, hybri...Big data conference europe   real-time streaming in any and all clouds, hybri...
Big data conference europe real-time streaming in any and all clouds, hybri...
Timothy Spann
 
D1-3-Signaling
D1-3-SignalingD1-3-Signaling
D1-3-Signaling
Oleg Levy
 
AMF Flash and .NET
AMF Flash and .NETAMF Flash and .NET
AMF Flash and .NET
Yaniv Uriel
 
HTML5 Programming
HTML5 ProgrammingHTML5 Programming
HTML5 Programming
hotrannam
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax Push
Doris Chen
 
Data power v7 update - Ravi Katikala
Data power v7 update - Ravi KatikalaData power v7 update - Ravi Katikala
Data power v7 update - Ravi Katikala
floridawusergroup
 
WSO2 Intro Webinar - Scale your business with the cloud enabled WSO2 Applica...
WSO2 Intro Webinar -  Scale your business with the cloud enabled WSO2 Applica...WSO2 Intro Webinar -  Scale your business with the cloud enabled WSO2 Applica...
WSO2 Intro Webinar - Scale your business with the cloud enabled WSO2 Applica...
WSO2
 

Semelhante a Real time web apps (20)

Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
Big data conference europe real-time streaming in any and all clouds, hybri...
Big data conference europe   real-time streaming in any and all clouds, hybri...Big data conference europe   real-time streaming in any and all clouds, hybri...
Big data conference europe real-time streaming in any and all clouds, hybri...
 
Signal R 2015
Signal R 2015Signal R 2015
Signal R 2015
 
D1-3-Signaling
D1-3-SignalingD1-3-Signaling
D1-3-Signaling
 
AMF Flash and .NET
AMF Flash and .NETAMF Flash and .NET
AMF Flash and .NET
 
Introduction to SignalR
Introduction to SignalRIntroduction to SignalR
Introduction to SignalR
 
HTML5 Programming
HTML5 ProgrammingHTML5 Programming
HTML5 Programming
 
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
 
Training Webinar: Enterprise application performance with server push technol...
Training Webinar: Enterprise application performance with server push technol...Training Webinar: Enterprise application performance with server push technol...
Training Webinar: Enterprise application performance with server push technol...
 
Bigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_appBigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_app
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax Push
 
Data power v7 update - Ravi Katikala
Data power v7 update - Ravi KatikalaData power v7 update - Ravi Katikala
Data power v7 update - Ravi Katikala
 
Scenic City Summit (2021): Real-Time Streaming in any and all clouds, hybrid...
Scenic City Summit (2021):  Real-Time Streaming in any and all clouds, hybrid...Scenic City Summit (2021):  Real-Time Streaming in any and all clouds, hybrid...
Scenic City Summit (2021): Real-Time Streaming in any and all clouds, hybrid...
 
Shopzilla On Concurrency
Shopzilla On ConcurrencyShopzilla On Concurrency
Shopzilla On Concurrency
 
Design patternsforiot
Design patternsforiotDesign patternsforiot
Design patternsforiot
 
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
 
Introduction to Apache Mesos and DC/OS
Introduction to Apache Mesos and DC/OSIntroduction to Apache Mesos and DC/OS
Introduction to Apache Mesos and DC/OS
 
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.jsAsynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
 
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at ScaleJUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
 
WSO2 Intro Webinar - Scale your business with the cloud enabled WSO2 Applica...
WSO2 Intro Webinar -  Scale your business with the cloud enabled WSO2 Applica...WSO2 Intro Webinar -  Scale your business with the cloud enabled WSO2 Applica...
WSO2 Intro Webinar - Scale your business with the cloud enabled WSO2 Applica...
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 

Real time web apps

  • 2. OVERVIEW 1.Introduction & Applications 2.Low level real-time implementation 3.Real-time Technologies 4.Sample code 5.Demo(HTTP polling, HTTP streaming, WebSocket)
  • 3. WHAT ARE REAL-TIME WEB APPS? • Allows users to receive information as soon as it is published • Bi-directional communication between clients & server • Both pull and push based systems
  • 4. EXAMPLES & APPLICATIONS • Gmail • Facebook • Twitter • Chat Services • Online Gaming • Notification and signaling • Shows live data • Easy collaboration
  • 10. REAL-TIME “HACKS” •Long polling •HTTP Streaming •AJAX (XMLHTTPRequest & InnerHTML)
  • 11. AJAX REQUEST • Window.open() • HTTP Request browser will stop or hang for the server response • Xmlhttp.open() • Ajax request is Async, java script does not have to wait for the server response, so it can execute other scripts and respond to user events while waiting for server response
  • 12. CONS OF “HACKS” •http web server timeouts •Too many connections •Too much overhead •Only a workaround and not a native solution
  • 13. WEBSOCKET PROTOCOL •Websocket is a Full Duplex Web Protocol •Two-way messaging over single connection •Low over-head
  • 14. WEBSOCKET PERFORMANCE • Each HTTP Request/Response (header + body) have minimum of 871 Bytes over head • WebSocket frames has 2 Bytes of over head • 1000 HTTP Clients polling per second = 6.6Mbps Network throughput • 1000WebSocket Clients receiving messages per second = 0.015Mbps Network throughput
  • 16. REAL-TIME TECHNOLOGIES • Self hosted (PaaS) Why use an existing solution? • Support/Community • Maintenance • Future features • Scaling • Eg: Pusher, PubNub, Firebase, realtime.co & deepstreamHub
  • 19. DEV LIBRARIES • Websocket & Messaging libraries • Publish / Subscribe libraries • Data-Sync • Hybrids
  • 20.
  • 21. WEBSOCKET & MESSAGING LIBRARIES FEATURES • heartbeats / keep alive calls these are tiny messages that are send on pre-defined intervals.They make sure that the other side is still responsive and prevent certain network constructs like proxies or firewalls from cutting your connection due to inactivity. • reconnecting if your connection drops, you want it to be re-established. Some libraries also queue messages while the connection is down and resend them once it becomes available again.
  • 22. WEBSOCKET & MESSAGING LIBRARIES FEATURES • http fallback if WebSockets are not available, some libraries fall back to http long polling and other techniques to mimic bi- directional communication (collectively known as "comet"). Depending on your target audience this might not be a necessity, but is still a good choice if your app needs to be available within large corporate infrastructures.
  • 23. WEBSOCKET LIBRARIES • engine.io Engine.io is the transport layer that powers socket.io, but can also be used as a standalone library. It incorporates a few unusual design choices, such as starting with http long-polling to ensure immediate connectivity and only upgrade the connection to websocket a bit later. • WS A solid, barebone WebSocket server for node.js Used by engine.io • SockJS A fast JavaScript / Node.js abstraction layer for websockets, supporting a number of fallback techniques
  • 24. WEBSOCKET LIBRARIES • Tornado Tornado is a general purpose networking library for Python, offeringWebsocket abstractions and fallbacks. • web-socket-js Flash based websocket implementation • libwebsocket Really fast websocket implementation in low level C. • Fleck Fleck is a WebSocket implementation in C#
  • 25. WEBSOCKET LIBRARIES • Atmosphere Atmosphere is a general websocket abstraction layer for JVM compatible languages. It's focused to run on Java and J2EE application servers and comes with an ecosystem of extension points to connect it to caches like Redis or Hazelcast. • Java Web Socket Exactly what the name suggests
  • 26. WEBSOCKET LIBRARIES • Mojolicious A websocket implementation with fallbacks for Perl • SignalR WebSocket abstraction for .NET • SuperWebSocket TCP/Websocket library for .NET • Plezy WebSocket abstraction for Ruby
  • 27. PUBLISH / SUBSCRIBE • Real-time messaging • Many clients subscribe to a topic (sometimes also called an event, namespace or channel) and other clients publish messages on that topic.This is a simple and scalable pattern for many-to-many communication.
  • 28. PUBLISH / SUBSCRIBE LIBRARIES • socket.io Definitely the most popular. Socket.io is a Node.js library that comes with clients in many languages. It offers direct messaging and pub-sub based on rooms (think chat-rooms) with the ability to distribute load across multiple nodes using a Redis server in the background. • socket cluster A pub-sub framework built in Node.js that focuses on load-balancing connections across a larger cluster of processes. • Centrifugo A backend agnostic pub-sub system written in Go
  • 29. PUBLISH / SUBSCRIBE LIBRARIES • Faye One of the first pub/sub systems around. Faye offers servers in both Ruby and Node and implements the Bayeux Protocol, designed 2007 by the Dojo foundation. Similar to socket.io, Faye relies on Redis pub/sub to scale across multiple nodes. It does however lack support for Redis clusters which limits its scalability to a single Redis instance. • Firehose.io A simple, Ruby based pub-sub system with integration points for Backbone and Ember. • Phoenix Framework Phoenix is a whole web-app framework for Erlang, but with a focus on pub/sub via channels.
  • 30. DATA-SYNC • Why not Pub/Sub? • User A changes some data and hits save.The data is send via ajax to a server and stored in a database. The client now publishes an event, e.g. Data-update/<some-id> . Other clients receive this event, make an ajax request to the server and download the updated data. • Data-sync models your data as observable objects or tree-structures that can be manipulated by clients and servers. Any change to the data is immediately synchronized across all connected clients. • This significantly reduces request-overhead, makes applications faster and development simpler.
  • 31. DATA-SYNC LIBRARIES • Horizon RethinkDB’s Horizon - a Node.js server and associated JavaScript client library that sits on top of RethinkDB and exposes its database and realtime querying capabilities to browser apps. Horizon supports authentication via openAuth and JSON webtoken and access control viaTOML configured permissions for user groups • FeatherJS FeatherJS is a RESTful CRUD framework for Node build on top of express.js that sends out events via a socket.io connection whenever an object is created, updated or deleted, allowing clients to react accordingly.
  • 32. REMOTE PROCEDURE CALL (RPC) / REMOTE METHOD INVOCATION (RMI) not strictly a realtime concept, but more the classical REST/HTTP request/response workflow, mapped onto a bi-directional connection. RPC allows you to call methods on a remote server and process their response.This can be a powerful concept in itself, but it becomes even more powerful when used in conjunction with other realtime concepts like pub/sub or data-sync
  • 33. HYBRIDS • In a voting system you might want to send a user’s vote as a remote method invocation - which increment the number of votes on a data-sync object as well as block the voting user from voting more than once. • For multiplayer games it can make sense to rely on simple pub-sub messaging to update player positions whilst using data-sync to keep track of scores.
  • 34. HYBRIDS • Deepstream.io Deepstream.io is a realtime server that combines data-sync with pub/sub and request response. It offers an open ecosystem of connectors for databases, caches and messaging systems. Its unobtrusive client plays well with any M*C framework and comes with plugins for React, Polymer and other libraries. • Meteor Meteor is a full stack framework for realtime apps, featuring data-sync, pub/sub, RPCs, realtime search and a host of other features. It offers a highly structured and opinionated way to set up and connect servers and databases, build clients and test and deploy applications. It comes with its own, self-contained ecosystem, including a proprietary (potentially soon to be deprecated?) package manager and originally its own client side templating library.
  • 35. HYBRIDS • Autobahn Autobahn offers Pub/Sub and RPC. It's a server implementing the WAMP (Web Application Messaging Protocol) spec and offers a selection of clients for JS, Python,Android and C++. • CometD CometD has been one of the first entries in the realtime space. It combines pub/sub with rpcs and supports browser connectivity via a stack of comet techniques.
  • 36. LIBS BASED ON LANGUAGE • Java: Netty, Jetty • JavaScript (Node.JS): Faye, Socket.IO (Engine.IO), Primus.io • .NET (C#): SignalR, XSockets • Python: Lots of options built on Tornado • PHP: ReactPHP, Ratchet • Ruby: Faye
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.