SlideShare a Scribd company logo
Real-time
Communication
Client-Server

Alexei Skachykhin – Software Engineer
iTechArt, 2014
Pull model
Xhr

Xhr

Xhr
Real-time
Use cases

Live feeds
Real-time
Use cases

Multiplayer games
Real-time
Use cases

Live sync applications
Pull & push model
Xhr

?

Xhr

Xhr

?

?
Real-time
Workarounds

Comet

Polling

Long
Polling

HTTP
Streaming
Polling
Periodic XHR requests aimed to simulate
push model
Polling

Interaction diagram
Polling

Request & response
POST http://q90.queuev4.vk.com/im705 HTTP/1.1
Accept: */*
X-Requested-With: XMLHttpRequest

HTTP/1.1 200 OK
Server: nginx/1.2.4
Date: Tue, 21 Jan 2014 23:22:31 GMT
Content-Type: text/javascript; charset=UTF-8
Content-Length: 180
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-store
[{"ts":"1103498799","events":["14<!>like_post<!>30602036_99896<!>2802<!>738<!>261"]}]
Demo
Polling
Polling

Protocol overhead

Actual overhead of HTTP headers in case
of VK.com is 1.4K
Polling

Network throughput

Overhead, K

Polling
interval, s

Number of
clients

Throughput,
Mbps

1.4

60

10000

1.1

1.4

1

10000

66

1.4

10

100000

66

(example statistics for vk.com)
Polling
Characteristics

-

High latency
High server workload
High protocol overhead (HTTP headers)
Potential cause of high battery drain

+ High degree of support across different browsers
Comet
Periodic long-lived XHR requests aimed to
simulate push model
Comet
Types

Long
polling

HTTP
Streaming
Long Polling
Interaction diagram
Demo
Long Polling
Long Polling
Characteristics

+ Reduced latency
+ Reduced server workload
+ Reduced protocol overhead (HTTP headers)
- Tricky server configuration
- Possible difficulties with intermediaries
- Can cause stoppage of all requests until long polling returns
HTTP Streaming
Comet technique similar to long polling
but instead of closing connection, infinitely
pushing data into it
HTTP Streaming
Interaction diagram
HTTP Streaming
Request & response
GET /events HTTP/1.1
Accept: application/json

Invented in 1994 by
Netscape
HTTP/1.1 200 OK
Content-Type: multipart/x-mixedreplace;boundary=separator
Transfer-Encoding: chunked
--separator
{ “id": 1, "x": 137, "y": 21 }
--separator
{ “id": 2, "x": 18, "y": 115 }
--separator
{ “id": 7, "x": 99, "y": 34 }
Demo

HTTP Streaming
HTTP Streaming
Browser compatibility

10
HTTP Streaming
Characteristics
-

Patchy browser support (Issue 249132)
Tricky server configuration
Possible difficulties with intermediaries
Can cause stoppage of all requests until long polling returns

+ Reduced latency
+ Reduced server workload
+ Reduced protocol overhead (HTTP headers)
HTML5

Pave the Cowpaths

When a practice is already widespread among
authors, consider adopting it rather than
forbidding it or inventing something new.
Server-Sent Events
Comet mechanism build directly into Web
browser

www.w3.org/TR/eventsource
Server-Sent Events
API

var source = new EventSource(‘/events');
source.addEventListener('message', function (e) {
console.log(e.data);
});

source.addEventListener('open', function (e) {
// Connection was opened.
});
source.addEventListener('error', function (e) {
if (e.readyState == EventSource.CLOSED) {
// Connection was closed.
}
});
Server-Sent Events
Request & response
GET /events HTTP/1.1
Accept: text/event-stream

HTTP/1.1 200 OK
Content-Type: text/event-stream

id: 12345
data: GOOG
data: 556
retry: 10000
data: hello world
data: {"msg": "First message"}
event: userlogon
Demo

Server-Sent Events
Server-sent Events
Browser compatibility

5.0

caniuse.com/#feat=eventsource
Server-sent Events
Advantages

+ Complexity is hidden from developer
+ Built-in reconnect
+ Standardized an agreed upon implementation
Pull & push model
Xhr

Xhr

Xhr

Xhr

Xhr

Xhr
Pull & push model
Flaws
-

HTTP one request – one resource semantics
Semi-duplex communications
Some degree of non-networking latency
Protocol overhead (HTTP headers)
Full-duplex model
?

?

?
Web Sockets
Low-latency bi-directional client-server
communication technology

www.w3.org/TR/websockets
Web Sockets
Full-duplex socket connection
Web Socket protocol v13 (RFC 6455) instead of HTTP
Uses HTTP for connection establishment
Web Sockets
Connection

var connection = new WebSocket('ws://html5rocks.websocket.org/echo');

Connection established by “upgrading” from HTTP to WebSocket
protocol
Runs via port 80/443 to simplify firewalls traversal
Pseudo schemes: ws, wss
Web Sockets
Connection handshake

GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13

Client sends GET or CONNECT
request to Web Socket endpoint
Upgrade header indicates willing to
upgrade connection from HTTP to
Web Socket
Web Sockets
Connection handshake

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

Server responds with 101 status
code and connection upgrade
header
From now on Web Socket protocol
will be used instead of HTTP
Web Sockets
API

var connection = new WebSocket('ws://html5rocks.websocket.org/echo');
// When the connection is open, send some data to
the server.
connection.onopen = function () {
// Send the message 'Ping' to the server.
connection.send('Ping');
};

// Log errors
connection.onerror = function (error) {
// Log messages from the server
console.log('WebSocket Error ' + error);
};
connection.onmessage = function (e) {
console.log('Server: ' + e.data);
};
Demo
Web Sockets
Web Sockets
Server compatibility

IIS8 + Native Web Sockets

NodeJS + Socket.io

Apache + apache-websocket
Web Sockets
Browser compatibility

10

6.0

caniuse.com/#feat=websockets
Web Sockets
Characteristics

+
+
+
+

Low latency
Low server workload
Low protocol overhead
Full-duplex

- Multiple versions of protocol to support
- Possible difficulties with intermediaries
- Requires up-to-date browser
What to choose?
Bleeding Edge

Polling

Simplicity

Comet /
Server-Sent
Events

Web Sockets

WebRTC

Efficiency
All in one
It is possible to abstract communication
details away from developer into libraries
Demo

Socket IO & SignalR
Caveats
1. Some network topologies may prohibit long-lived connections
2. Intermediaries are still barely aware of Web Sockets
3. Long-lived connections are subject to spontaneous shutdown
4. Long-lived connections can prevent some browsers from spanning
parallel HTTP requests

5. Web Sockets spec has bunch of legacy versions
Links
Code samples:

https://github.com/alexeiskachykhin/web-platform-playground
Links
Socket IO:
http://socket.io/
SignalR:
http://signalr.net/
Live Sync Demos:
http://www.frozenmountain.com/websync/demos/
Web Socket – TCP bridge:
http://artemyankov.com/tcp-client-for-browsers/
Server-Sent Events:
http://www.html5rocks.com/en/tutorials/eventsource/basics/
Web Sockets:
http://www.websocket.org/
Thank you!
Forward your questions to
alexei.skachykhin@live.com

More Related Content

What's hot (20)

PPTX
NServiceBus_for_Admins
Adam Fyles
 
PPT
Getting started with ASPNET Core SignalR
Nemi Chand
 
PPTX
Behind the scenes of Real-Time Notifications
Guillermo Mansilla
 
PPTX
Forcelandia 2018 - Create lively lightning components with streaming api
Anshul Verma
 
PPTX
SignalR
Eyal Vardi
 
PDF
Live Streaming & Server Sent Events
tkramar
 
PPTX
Cache control directive
Mohamed Mamoon
 
PDF
The RED Method: How To Instrument Your Services
Kausal
 
PPT
Reverse proxy
Proxies Rent
 
PPTX
Web Socket
Jack Bui
 
PPT
Reverse proxy
Proxies Rent
 
PPTX
03 spring cloud eureka service discovery
Janani Velmurugan
 
PPTX
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
Sencha
 
PPTX
Application latency and streaming API
streamdata.io
 
PPT
Dyna trace
Yasmine Gaber
 
PPTX
Introduction to web socket
HarunRRayhan
 
PPTX
Api RESTFull
Germán Küber
 
PPTX
Apinizer - Full API Lifecycle and Integration Platform
Mustafa Yildiz
 
PPTX
Large Scale Test Automation
Ashot Karapetyan
 
PPTX
Clean up this mess - API Gateway & Service Discovery in .NET
Marcin Tyborowski
 
NServiceBus_for_Admins
Adam Fyles
 
Getting started with ASPNET Core SignalR
Nemi Chand
 
Behind the scenes of Real-Time Notifications
Guillermo Mansilla
 
Forcelandia 2018 - Create lively lightning components with streaming api
Anshul Verma
 
SignalR
Eyal Vardi
 
Live Streaming & Server Sent Events
tkramar
 
Cache control directive
Mohamed Mamoon
 
The RED Method: How To Instrument Your Services
Kausal
 
Reverse proxy
Proxies Rent
 
Web Socket
Jack Bui
 
Reverse proxy
Proxies Rent
 
03 spring cloud eureka service discovery
Janani Velmurugan
 
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
Sencha
 
Application latency and streaming API
streamdata.io
 
Dyna trace
Yasmine Gaber
 
Introduction to web socket
HarunRRayhan
 
Api RESTFull
Germán Küber
 
Apinizer - Full API Lifecycle and Integration Platform
Mustafa Yildiz
 
Large Scale Test Automation
Ashot Karapetyan
 
Clean up this mess - API Gateway & Service Discovery in .NET
Marcin Tyborowski
 

Viewers also liked (20)

PPTX
Real time Communication
Aryan goyal
 
PDF
Introduction to WebRTC
Patrick Cason
 
PPTX
WebRTC Seminar Report
srinivasa teja
 
PDF
Real-Time Web: The future web in the enterprise
Teemu Arina
 
PDF
The Real-Time Web and its Future
ReadWrite
 
PPTX
Evaluating Extensions: A Comprehensive Guide to Keeping Your Site Clean
Will Strohl
 
PDF
Cloud Company - Designing a Faster and More Intelligent Organization for the ...
Teemu Arina
 
PDF
Cloud Company: Social Technologies and Practices in Strategy, Management, and...
Teemu Arina
 
PPTX
DNN Database Tips & Tricks
Will Strohl
 
PPTX
Build a DNN Module in Minutes
Will Strohl
 
PPTX
DNN Connect 2014 - Enterprise Ecommerce and DotNetNuke
Thomas Stensitzki
 
PPT
DotNetNuke CMS: benefits for web professionals
I-business Solutions
 
PPT
Dot Net Nuke Presentation
Tony Cosentino
 
PPTX
DotNetNuke: Be Like Bamboo
Will Strohl
 
DOC
Lv phát triển các dịch vụ giá trị gia tăng (vas) của tập đoàn viễn thông quân...
Giang Coffee
 
PDF
Our Bodies, Disconnected: The Future Of Fitness APIs
ReadWrite
 
PDF
Vision of the future: Organization 2.0
Teemu Arina
 
PPTX
Networks, Networks Everywhere, And Not A Packet To Drink
ReadWrite
 
PDF
Upgrade Your Work Day With Quantified Self & Biohacking
Teemu Arina
 
PPTX
Фестиваль открытых уроков
killaruns
 
Real time Communication
Aryan goyal
 
Introduction to WebRTC
Patrick Cason
 
WebRTC Seminar Report
srinivasa teja
 
Real-Time Web: The future web in the enterprise
Teemu Arina
 
The Real-Time Web and its Future
ReadWrite
 
Evaluating Extensions: A Comprehensive Guide to Keeping Your Site Clean
Will Strohl
 
Cloud Company - Designing a Faster and More Intelligent Organization for the ...
Teemu Arina
 
Cloud Company: Social Technologies and Practices in Strategy, Management, and...
Teemu Arina
 
DNN Database Tips & Tricks
Will Strohl
 
Build a DNN Module in Minutes
Will Strohl
 
DNN Connect 2014 - Enterprise Ecommerce and DotNetNuke
Thomas Stensitzki
 
DotNetNuke CMS: benefits for web professionals
I-business Solutions
 
Dot Net Nuke Presentation
Tony Cosentino
 
DotNetNuke: Be Like Bamboo
Will Strohl
 
Lv phát triển các dịch vụ giá trị gia tăng (vas) của tập đoàn viễn thông quân...
Giang Coffee
 
Our Bodies, Disconnected: The Future Of Fitness APIs
ReadWrite
 
Vision of the future: Organization 2.0
Teemu Arina
 
Networks, Networks Everywhere, And Not A Packet To Drink
ReadWrite
 
Upgrade Your Work Day With Quantified Self & Biohacking
Teemu Arina
 
Фестиваль открытых уроков
killaruns
 
Ad

Similar to Web Real-time Communications (20)

PPTX
Basic understanding of websocket and and REST API
divyabiru27
 
PPTX
Taking a Quantum Leap with Html 5 WebSocket
Shahriar Hyder
 
ZIP
Websockets at tossug
clkao
 
PPTX
Codecamp Iasi-26 nov 2011 - Html 5 WebSockets
Florin Cardasim
 
PPTX
Codecamp iasi-26 nov 2011-web sockets
Codecamp Romania
 
PPTX
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
jeetendra mandal
 
PPT
Web-Socket
Pankaj Kumar Sharma
 
PPTX
Building real-time-collaborative-web-applications
Harbinger Systems - HRTech Builder of Choice
 
PDF
Decoding real time web communication
AMiT JAiN
 
PDF
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
PDF
HTML5/JavaScript Communication APIs - DPC 2014
Christian Wenz
 
PDF
Intro to WebSockets and Comet
dylanks
 
PDF
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET Journal
 
PPTX
Fight empire-html5
Bhakti Mehta
 
PPTX
Webinar slides "Building Real-Time Collaborative Web Applications"
Sachin Katariya
 
PPTX
Interactive web. O rly?
timbc
 
PPTX
ClientServer Websocket.pptx
MaxamedSheekhAmiin
 
PDF
What is a WebSocket? Real-Time Communication in Applications
Inexture Solutions
 
PPT
HTTP Server Push Techniques
Folio3 Software
 
PDF
Using Communication and Messaging API in the HTML5 World
Gil Fink
 
Basic understanding of websocket and and REST API
divyabiru27
 
Taking a Quantum Leap with Html 5 WebSocket
Shahriar Hyder
 
Websockets at tossug
clkao
 
Codecamp Iasi-26 nov 2011 - Html 5 WebSockets
Florin Cardasim
 
Codecamp iasi-26 nov 2011-web sockets
Codecamp Romania
 
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
jeetendra mandal
 
Building real-time-collaborative-web-applications
Harbinger Systems - HRTech Builder of Choice
 
Decoding real time web communication
AMiT JAiN
 
Building Next Generation Real-Time Web Applications using Websockets
Naresh Chintalcheru
 
HTML5/JavaScript Communication APIs - DPC 2014
Christian Wenz
 
Intro to WebSockets and Comet
dylanks
 
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET Journal
 
Fight empire-html5
Bhakti Mehta
 
Webinar slides "Building Real-Time Collaborative Web Applications"
Sachin Katariya
 
Interactive web. O rly?
timbc
 
ClientServer Websocket.pptx
MaxamedSheekhAmiin
 
What is a WebSocket? Real-Time Communication in Applications
Inexture Solutions
 
HTTP Server Push Techniques
Folio3 Software
 
Using Communication and Messaging API in the HTML5 World
Gil Fink
 
Ad

More from Alexei Skachykhin (6)

PPTX
CSS Architecture: Writing Maintainable CSS
Alexei Skachykhin
 
PPTX
Representational State Transfer
Alexei Skachykhin
 
PPTX
Code Contracts
Alexei Skachykhin
 
PPTX
JavaScript as Development Platform
Alexei Skachykhin
 
PDF
HTML5 Comprehensive Guide
Alexei Skachykhin
 
PPTX
Windows 8
Alexei Skachykhin
 
CSS Architecture: Writing Maintainable CSS
Alexei Skachykhin
 
Representational State Transfer
Alexei Skachykhin
 
Code Contracts
Alexei Skachykhin
 
JavaScript as Development Platform
Alexei Skachykhin
 
HTML5 Comprehensive Guide
Alexei Skachykhin
 

Recently uploaded (20)

PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
July Patch Tuesday
Ivanti
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
July Patch Tuesday
Ivanti
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 

Web Real-time Communications