7. Implementation
Websocket SSE
• Request 101 => to
Upgrade to websocket
• OPEN / MESSAGE /
CLOSE
• Error handling to be
build
• HTTP !
• No upgrade / Error
handling specified
(reconnection / event
ID)
8. Web infra compatibility
(Load balancer, server and/or proxy)
Websocket SSE
Reconfigurations required
!
(Fall-back mechanism is a
must!)
No changed
required
9. Websocket vs REST
“POST” to one client
Source : Arun Guptar
• 10 messages of 1 byte : 7ms vs 220 ms
• 100 messages of 10 bytes : 57 vs 986 ms
• 1000 messages of 100 bytes : 200 vs 10210 ms
• 5000 messages of 1000 bytes : 1,2 sec vers 54 sec.
10. Web latency
500 tweets :
• Safari: 7 seconds using SSE and 16 seconds
using WebSockets
• Chrome: 5 seconds using SSE and 8 seconds
using WebSockets
• Firefox: 6 seconds using SSE and 8 seconds
using WebSockets
Source : http://matthiasnehlsen.com/
11. Solutions for dynamic data
Streams Browser
support
Web infra
compatibility
Easiness to
dev
Load
(network /
Device)
App latency
Polling/Lon
g Polling
Bi-dir
Websocket Bi-dir
SSE Uni-dir
Socket.io
https://www.playframework.com/
12. Why ? To improve UX
• Overall latency : 100ms = 5% page view + 1% revenue
• Make your app/site “alive & real” with real-time data
• Stock of service/material, prices, news, social networks, …
• Historically real-time based
• Chat
• Stock market, bet odds, traffic, …
• TV second screen
• When time influences decisions
• Limited resources (sharing economy)
• …
17. But …
• Unable to add header to URI with JS SSE
librairies
• Unable to detect disconnection
18. But …
• Unable to add header to URI with JS SSE
librairies
Use query parameters for token, Oauth
• Unable to detect disconnection
Heart beat with 0 data