do we still need servers? p2p web apps distribution

72

Upload: denis-radin

Post on 08-Jan-2017

413 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Do we still need servers? P2P web apps distribution
Page 3: Do we still need servers? P2P web apps distribution
Page 4: Do we still need servers? P2P web apps distribution
Page 5: Do we still need servers? P2P web apps distribution
Page 6: Do we still need servers? P2P web apps distribution

What is beyond isomorphic?

orP2P web apps distribution

Page 7: Do we still need servers? P2P web apps distribution
Page 8: Do we still need servers? P2P web apps distribution

Let`s go retrospectiveAnd see how responsibilities sharing

between client and server was changing

Page 9: Do we still need servers? P2P web apps distribution

In the beginning there was nothing...

Page 10: Do we still need servers? P2P web apps distribution

And then god created a server and client

Page 11: Do we still need servers? P2P web apps distribution

Server was responsible for everything

Page 12: Do we still need servers? P2P web apps distribution

And client was just displaying HTML

Page 13: Do we still need servers? P2P web apps distribution

On the second day god created SPA paradigm

Page 14: Do we still need servers? P2P web apps distribution

And client become responsible for a view

layer

Page 15: Do we still need servers? P2P web apps distribution
Page 16: Do we still need servers? P2P web apps distribution

On the third day god created isomorphism

Page 17: Do we still need servers? P2P web apps distribution
Page 18: Do we still need servers? P2P web apps distribution

Why isomorphic is cool?Powers of server side rendering

and SPA are combined

Page 19: Do we still need servers? P2P web apps distribution

Server renderingmeans faster app delivery

Page 20: Do we still need servers? P2P web apps distribution

Server renderingmeans search engines optimisation

Page 21: Do we still need servers? P2P web apps distribution

Single pagemeans better responsivity

Page 22: Do we still need servers? P2P web apps distribution

Isomorphic toolingPretty powerful because of high demand

Page 23: Do we still need servers? P2P web apps distribution
Page 24: Do we still need servers? P2P web apps distribution
Page 25: Do we still need servers? P2P web apps distribution

Let`s sum up

Page 26: Do we still need servers? P2P web apps distribution

First day

When server is everything

Server Client

UI rendering + -

Data retrieval + -

App delivery + -

Page 27: Do we still need servers? P2P web apps distribution

Second day (SPA)

WOW! We can do some things on client - side, lets SPA everything!

Server Client

UI rendering - +

Data retrieval - +

App delivery + -

Page 28: Do we still need servers? P2P web apps distribution

Third day (Isomorphic)

Ok, let`s use all powers we have now

Server Client

UI rendering + +

Data retrieval + +

App delivery + -

Page 29: Do we still need servers? P2P web apps distribution

Fourth day?

Page 30: Do we still need servers? P2P web apps distribution

On the fourth day god created WebRTC and

said“Every browser can deliver content to the rest,

bypassing server. Do something with this!”

Page 31: Do we still need servers? P2P web apps distribution

What is WebRTC?Browser API designedfor P2P communication

Page 32: Do we still need servers? P2P web apps distribution
Page 33: Do we still need servers? P2P web apps distribution

Fourth day?

Let`s break the boundaries to have more powers!

Server Client

UI rendering + +

Data retrieval + +

App delivery + +

Page 34: Do we still need servers? P2P web apps distribution

Why P2P is cool?Powers of self-maintainable CDN,

server side rendering and SPA are combined

Page 35: Do we still need servers? P2P web apps distribution

Reduce distancesget application from seeds near you to reduce latency

Page 36: Do we still need servers? P2P web apps distribution

Traditional app distributionIt takes a lot of transatlantic trips to transmit an app when doing it in a traditional way.

Page 37: Do we still need servers? P2P web apps distribution

P2P app distributionP2P allows to reduce number of transcontinental transfers and reduce server load.

Page 38: Do we still need servers? P2P web apps distribution

Use fasternetworkget application from company`s internal network once it got there

Page 39: Do we still need servers? P2P web apps distribution

Traditional app distributionServer sends package many times, corporative internet channels are loaded appropriately.

Page 40: Do we still need servers? P2P web apps distribution

P2P app distributionIn case of P2P distribution application hits corporative network once and then is distributed using high speed internal network. This reduces server load and corporative internet channel load.

Page 41: Do we still need servers? P2P web apps distribution

How to enable browser to seed your app P2P?First client gets app + small JS snippet which enables browser to distribute app further via

WebRTC

Page 42: Do we still need servers? P2P web apps distribution

Application code

Basically any HTML/JS content

Viraladdition

Serves app P2P

distribution

+

What first browser gets from server

Page 43: Do we still need servers? P2P web apps distribution

Browser essentially gets infected by app

And can infect others…

Page 44: Do we still need servers? P2P web apps distribution

Thin client

Serves getting app from other browser

What every next client gets from server

Page 45: Do we still need servers? P2P web apps distribution

Thin client

Serves getting app from other browser

Then it connects to other browser via WebRTC

Application code

Basically any HTML/JS content

Viraladdition

Serves app P2P

distribution

+P2P

Page 46: Do we still need servers? P2P web apps distribution
Page 47: Do we still need servers? P2P web apps distribution

Viral JavaScriptServer Client

UI rendering + +

Data retrieval + +

App delivery + +

Clients demand for more rights!

Page 48: Do we still need servers? P2P web apps distribution

Let`s do some mathWarning! You ll need some patience...

Page 49: Do we still need servers? P2P web apps distribution

Load speed math modelMa - app size (HTML, JS, CSS)

Madd - viral addition size

Mt - thin client size

Bint - Internet speed

Bnet - internal company network speed

Page 50: Do we still need servers? P2P web apps distribution

Load speed math model● Ma - app size (HTML, JS, CSS)● Madd - viral addition size● Mt - thin client size● Bint - Internet speed● Bnet - internal company network speed

Tn = Ma / Bint - application transfer time when done in traditional way over Internet

Tp2p = (Ma + Madd) / Bnet + Mt / Bint - viral addition and thin client are

being transfered via Internet and application body is sent over internal network

Page 51: Do we still need servers? P2P web apps distribution

Load speed calc● Ma - 1000 (1 Mb)● Madd - 50 (50 Kb)● Mt - 50 (50 Kb)● Bint - 1250 (10 Mbit average in Europe in Q2 2015 according to research)● Bnet - 1250000 (1 Gbit optic fiber)

Tn = 1000 / 1250 = 0.8 sec

Tp2p = (1000 + 50) / 125000 + 50 / 1250 = 0,0484 sec

Page 52: Do we still need servers? P2P web apps distribution

0,8 vs 0,0484 sec

1652% improvement

Page 53: Do we still need servers? P2P web apps distribution

Load speed (improved)● Ma - 3000● Madd - 10● Mt - 10● Bint - 1250● Bnet - 1250000

Tn = 3000 / 1250 = 2.4 sec

Tp2p = (3000 + 10) / 125000 + 10 / 1250 = 0,032 sec

Page 54: Do we still need servers? P2P web apps distribution

2,4 vs 0,032 sec

7500% improvement

Page 55: Do we still need servers? P2P web apps distribution

Is it realistic?No

Page 56: Do we still need servers? P2P web apps distribution

Not every user is P2PSomeone still need to be seeded from server

Page 57: Do we still need servers? P2P web apps distribution

Uavg = 5Let`s imagine that every corporative network your

application is distributed in have 5 users

Page 58: Do we still need servers? P2P web apps distribution

2,4 vs 0,032 sec

7500% improvementevery 5th need full package so our win is

7500 - (7500 / 5) = 6000%

Page 59: Do we still need servers? P2P web apps distribution

Is it realistic?No

Page 60: Do we still need servers? P2P web apps distribution

Handshake takes a lotSince it is ICEd

Page 61: Do we still need servers? P2P web apps distribution

The world without NATs

Page 62: Do we still need servers? P2P web apps distribution

Our world

Page 63: Do we still need servers? P2P web apps distribution

This adds 4 RTT at least400 msec in average

Page 64: Do we still need servers? P2P web apps distribution

2,4 vs 0,432 sec

550% improvementevery 5th need full package so our win is

550 - (550 / 5) = 440%

Page 65: Do we still need servers? P2P web apps distribution

Is it realistic?No

Page 66: Do we still need servers? P2P web apps distribution

But close to be =)

Page 67: Do we still need servers? P2P web apps distribution

WebTorrents?Why not this one?

Page 68: Do we still need servers? P2P web apps distribution

WebTorrents

Same but slower start since it establishes connection not just on WebRTC level but also via Torrent

protocol

Server Client

UI rendering + +

Data retrieval + +

App delivery + +

Page 69: Do we still need servers? P2P web apps distribution

Demo timepixelscommander.com:3000

Page 70: Do we still need servers? P2P web apps distribution

And the nicest one...

npm -i viraljs

var ViralContainer = require(’viraljs’);

myExpressApp.use(new ViralContainer().middleware);

Page 71: Do we still need servers? P2P web apps distribution
Page 72: Do we still need servers? P2P web apps distribution

github.com/PixelsCommander/ViralJS

Questions?

@PixelsCommander