83
Or maybe HTTP2.0 [SPeeDY] Andreas Bjärlestam 2012-02-23

SPDY - or maybe HTTP2.0

Embed Size (px)

DESCRIPTION

The SPDY protocol has been developed by Google since 2009. It is intended as an evolution of HTTP with better performance and network utilization.

Citation preview

Or maybe HTTP2.0

[SPeeDY]

Andreas Bjärlestam 2012-02-23

SPDY quick overview

• An evolution of HTTP• Developed by Google since 2009• Openly available spec

Why the hell would you want to replace HTTP?

HTTP is fantastic

it has totally changed the world

but…

HTTP is over 20 years old

HTTP 1.1 is 12 years old

Webpages in 1999

Webpages in 2012

Mobile internet usage

source: svenskarna och internet 2011 https://www.iis.se/docs/SOI2011.pdf

This is how more and more of us consume the web…

Often it feels a lot like…

People no longer have patience to wait for slow pages

Web pages February 2012

• www.facebook.com - ca 100 http requests• www.bostonglobe.com - ca 100 http requests• www.svtplay.se - ca 90 http requests• www.aftonbladet.se - ca 350 http requests

source: http://httparchive.org/

What does it look like over the network fetching 100 resources?

Can you spot the problem?

Its all synchronous

How come an advanced page like facebook.com loads in under 4

seconds when its all synchronous?

Hacky optimizations

CSS spritesbase64 images in data-urls

CSS concatenationJavaScript concatenation

HTTP/TCP

HTTP/TCP

HTTP/TCP

HTTP/TCP

HTTP/TCP

HTTP/TCP

6 x HTTP connections

What is the problem with this? Why not even more?

Wasted resources

TCP Congestion control

2 connections per host recommended by HTTP 1.1 spec

6 connections in most browsers

Domain sharding

• www.bostonglobe.com - 59 connections• www.svtplay.se - 22 connections• www.aftonbladet.se - 118 connections

source: http://www.webpagetest.org

We kind of abuse TCP when we open more

connections

and…

New TCP connections are slow

3 way handshake

On my macbookPing 20ms ≈ 30ms to set up a

connection

On my mobile (3G)Ping 300ms ≈ 450ms to set up a

connection

HTTP/TCP

HTTP/TCP

HTTP/TCP

HTTP/TCP

HTTP/TCP

TCP Slow start

HTTP/TCP

It turns out that page load time for a moderately complex site is almost no faster over 20mbits/sec than over 2mbits/sec

So… we need to utilize our TCP connections better

Enter

SPDY

Don’t we break the web if we replace HTTP?

Nope

The semantics of HTTP is kept

or in simpler words…

SPDY implements the HTTP API

HTTP -> SPDY

GETPUT

POST…

HEADERS

Use of URLs Use of TCP

GETPUT

POST…

HEADERS

Use of URLs Use of TCP

You can switch to SPDY with no changes to your web application

SPDY runs over TCP and will not require upgraded network

equipment

HTTP -> SPDY

TCP/IP

TLS/SSL

HTTP

TCP/IP

TLS/SSL

SPDY

HTTP

Designed with speed as

primary goal

1 TCP connection

HTTP/TCP

HTTP/TCP

But it will be on fire!

SPDY is multiplexed

This is a typical HTTP sessionGET

GET

GET

200 OK

200 OK

200 OK

MultiplexingGET 1

GET 2GET 3

200 OK 2

200 OK 3

200 OK 1

Stream priorities

SPDY is binary

Will be difficult to just fire up telnet and hack away

Every decent site will be encrypted and gzipped anyways

TLS/SSL is mandatory

Communication should be secure by default

Users should not have to care

Using SSL ensures that communication over existing

proxies is not broken

..but you will not be able to use proxies for caching etc

Headers are compressed

How will the client know that it can use SPDY towards a server?

NPN

TLS Next Protocol Negotiation

Server Push

Server Push

So is it worth it?

Google tested 25 of the “top 100” sites

Average speedup

39% - 55%

SPDY could make your life easier

Less need for hacky optimizations like CSS sprites, file concatenations,

domain sharding etc

Should I add SPDY support to my servers on Monday?

Probably not…

Implementations

• Apache mod_spdy• Nginx – in roadmap• node_spdy – requires node.js 0.7• netty• more…

Example…

Browsers

• Chrome (since version 6)• Firefox 11 (turned off by default)• (Amazon silk)

CDNs

• Strangeloop• Contendo

CDNs

SPDYGateway

Your web serverBrowser

Google

• Support SPDY on most of their services• 90% of their SSL traffic is over SPDY

Amazon silk

SilkBrowser

SPDYGateway

TheInternet

SPDY HTTP

The spec

• Draft spec, version 3• Plan is to submit it to IETF as input to HTTP2.0• IETF HTTPbis WG chair recently proposed to

start work on HTTP2.0

Alternatives

HTTP Pipelining

• Not as effective as multiplexing• Hard to implement in browser• Opera is the only desktop browser that has a

full implementation enabled by default• Android, IOS5 and Opera mobile browsers do

some amount of pipelining• Not used by most proxies

Pipelining

GET 1

GET 2GET 3

200 OK 1

200 OK 2

200 OK 3

GET 1

GET 2GET 3

200 OK 2

200 OK 3

200 OK 1

Multiplexing

GET

GET

GET

200 OK

200 OK

200 OK

Synchronous

Alternative transport protocols

• SCTP• BEEP

Roundup

• ~ 50% Faster page loads than HTTP• Backwards compatible with HTTP• Better utilization of TCP• Secured by default• Binary + compressed• Will likely be the base for HTTP2.0