Faster images through the WebSockets?
Yarik Ponomarenko
kyivJs '12
problem
Too many images at the webpage are downloaded slowly
How does browser load a image?
Browser
Server
Next is always waiting until previous is finished
Image 1
Server
Image 2
Browser use several connections
Queue 1
Queue 2
Queue ...
Queue 6
"keep alive" connections
without
keep alive
Current tricks to load images faster
What bad in HTTP Get?
the silver bullet trick is:
using websocket connection to retrieve images in async way
WebSocket (WS://)
why that faster?
HTTP GET
WebSocket
plan
client
backend
base64 has 30% lower density
how to read the binary WS frame?
another way to read blob
many requests in one connection:�send the message id
many requests in one connection:�return the message id
many requests in one connection:�parse the message id in response
Disadvantages
ITW client
example: ITW client
ITW backend
ITW backend - client interface
ITW Server
out
encoder
ITW client
ITW backend - image sources
ITW Server
input
STATIC
input
HTTP
WEB
HDD
example: ITW server
benchmark, Kiev - Novosibirsk
benchmark, Kiev - Kiev
leaflet.js + itw
async is better
HTTP GET
WebSocket
questions?
http://github.com/yarikos/itw
http://twitter.com/yarik_is