WebSocket is cool, and you probably already played with it. But it’s just a transport technology. If you have thousands of client connections you need to do lots of improvements to make it scalable, reliable and achieve high performance. You need to implement many things on top of it.
We are building financial data streaming platform for thousands of traders using WebSocket. I’m going to share my experience and cover such techniques as delta delivery, conflation, dynamic throttling, bandwidth and frequency limitation and other. I will also do a live demo of how to build scalable WebSocket backend from scratch using Java and Spring.
6. 6
HTTP
WHAT IS WEBSOCKET
GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
standard: tools.ietf.org/html/rfc6455
7. 7
HTTP
WHAT IS WEBSOCKET
HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
standard: tools.ietf.org/html/rfc6455
8. 8
TCP
HTTP
WHAT IS WEBSOCKET
HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
GET /demo HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
DATA DATA DATA DATA DATA
DATA DATA DATA DATA DATA
standard: tools.ietf.org/html/rfc6455
57. 57
High performance WebSocket backend
Position-based protocol
Delta delivery
Schema
Max frequency limit
Basic WebSocket backend
Dynamic bandwidth control
73. 73
No improvements
2 KB/s*Max frequency limit
400 B/s*Schema
370 B/s*Delta delivery
310 B/s*Position-based
420 B/s*Bandwidth control
-95%
-80%
-8%
-15%
+35%
33 KB/s*
* for demo application including gzip compression
BANDWIDTH OPTIMIZATION*
74. 74
READ
High Performance Browser Networking
What every web developer should know
about networking and web performance
Free reading: https://hpbn.co/
By Ilya Grigorik
Publisher: O'Reilly Media
Release Date: September 2013
76. 76
More Than Just WebSockets for Real-Time
Multiplayer Games and Collaboration
On YouTube and Slideshare
By Alessandro Alinone (CEO of Lightstreamer)