Atmosphere 2014: Scalability and Websockets: Creating a Websocket CDN with DIASP. - Michał...
-
Upload
proidea -
Category
Presentations & Public Speaking
-
view
284 -
download
0
description
Transcript of Atmosphere 2014: Scalability and Websockets: Creating a Websocket CDN with DIASP. - Michał...
SCALABILITY ANDWEBSOCKETS: CREATINGA WEBSOCKET CDN WITH
DIASP.Michal Czapracki (@budleigh_s), Agora SA / www.agora.pl [email protected]
IDENT
WHOAMIMICHAL CZAPRACKI
First bit of code written, 1989
First remote systemconnection, 1992
First website developed, 1995
First time grounded for thephone bill, 1996
First earning in the webbusiness, 1998
First serious job, 2001
Head of Video DevelopmentTeam at Agora SA since 2010
WHOIS AGORA.PLFounded, May 8th, 1989
Biggest Polish Owned MediaCompany
Owner of cinemas,newspapers, radio stations,
web portals, advertisingcompanies and more
Over 3000 employees
Employer of Michal Czaprackisince 2010 ;)
WEBSOCKET
WHAT ARE WEBSOCKETSW3C standard for client-server bi-directional messaging
First browser implementations in 2011, full major browsercoverage since 2012
Ready to use in 2014 in major browsers, web frameworks onclient and server side
WHERE COULD WEBSOCKETS BE USEDOnline gaming
Messenger apps
Long running server operations
Live feeds
Server side event based scenarios
HOW DID THE WORLD MANAGE BEFOREWEBSOCKETS
http polling
long polling
bare tcp/ip sockets using plugins
Really? It simply didn't
WEBSOCKET PROS&CONSInstant communication
Lower bandwidth usage
Duplex communication
Ready to use native libraries
Large number of concurrentconnections
Hard to implement in standardframeworks
Not compatible with most webproxies
No caching layer
LIVE APPLICATIONS
THE CHALLENGEThe internet was always dreaming of a cheap way to overtake
other media in terms on information time to market
So did Agora - in late 2011 we started developing a live mobileapplication for our sports portal
With estimations of some downloads in first months this was abig challenge
THE SCALEFirst months figures showed that the estimations weren't
exaggerated.
Our middleware had a hard time processing requests, andfurther horizontal scaling would overload our backends
Most processing time was taken by the traffic that we could notcache - websockets
THE SOLUTIONWe decided we need to create a dedicated software just to
handle the websocket traffic
The middleware could then just have a single upstreamconnection and our proxy will broadcast the messages to our
users
We built and deployed something we called DIASP (Diasp Is ASocket Proxy)
THE APPS
THE OUTCOMERight now Sport.pl Live and Gazeta.pl Live together have over 2
milion downloads on iOS, Android and Windows Phone
With just six DIASP instances we've got a stable system able tocope with 20.000 connections on a single intance
All we need to host a single instance is 300MB RAM and a tad ofprocessor power
In testing we kept breaking the routers... not DIASP.
DIASP IS A SOCKETPROXY
The questions that need answers.
WHAT IS DIASP?Diasp is an unidirectional websocket proxy server module
written in node.js
Like a web proxy it's designed to handle multiple clients from asingle upstream connection
It lets you send anything form server to client, blocks all incomingcommunication, hence it's unidirectionality
WHAT DOES DIASP DO?After you setup your diasp instance, Diasp will start a http
websocket server
When a client connects to the specified host or resource orprotocol, diasp will connect to one of the configured upstream
websocket server
Diasp will also translate between plain websockets, socket.io andif you implement it, also other means of communication
WHY ARE YOU TELLING ALL THIS?Well as of yesterday, DIASP is GPLed and published on Github
https://github.com/AgoraTech/diasp
You can install it from npm, modify one of the examples and runit.
npm install diasp
GET DIASP
INSTALL NODEJSUse your favorite way of installing node >= 0.6.x
Install using your favorite package manager
Grab your binary from nodejs.org
Build from source
INSTALL DIASPnpm install diasp
RUN DIASP SAMPLEStart the websocket server.
node samples/server/http-socket.io-relay
Start your diasp instance.node samples/server/diasp
Point your browser to wherever you've got your client files.
THANKS@BUDLEIGH_S