+ All Categories
Home > Documents > 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect...

2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect...

Date post: 04-Jun-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
37
HTTP/2 …. HTML5 Make the web fast Christian Horny
Transcript
Page 1: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

HTTP/2 …. HTML5Make the web fast

Christian Horny

Page 2: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

2

HTTP/2 goals

! Improve end-user perceived latency! Address the "head of line blocking"! Not require multiple connections! Retain the semantics of HTTP/1.1

Page 3: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

3

Usability Engineering

Jakob Nielsen

DELAY USER REACTION

0 - 100 ms Instant

100 – 300 ms Feels sluggish

300 - 1000 ms Machine is working...

1 s+ Mental context switch

10 s I'll come back later...

Page 4: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

4

How Fast Are Websites Around The World?

DesktopMedian: ~2.7sMean: ~6.9s

Mobile *Median: ~4.8sMean: ~10.2s

* optimistic

0 2 4 6 8 10 12

Mobile

Dektop

seconds

Page Load TimeMean Median

http://www.businessinsider.com

Page 5: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

5

e.g.: mysite.com -> m.mysite.com

Page 6: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

6

Requests and Transfer Size (browsing avg. 490.000 sites)

Content Type Avg # of Requests Avg size

HTML 9 60 kB

Images 56 1200 kB

Javascript 18 307 kB

CSS 6 64 kB

Webfont 2 80 kB

HTTP Archive - Trends (März, 2015)

Page 7: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

7

The network bandwidth will save us?Right, right? Or maybe not...

Page 8: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

8

Page 9: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

9

Page 10: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

10

LatencyDer Zeitraum zwischen einem verborgenen Ereignis und dem Eintreten einer sichtbaren Reaktion darauf

RTTDie Round Trip Time bzw. Paketumlaufzeit gibt die Zeit an, die ein Datenpaket in einem Rechnernetz benötigt, um von der Quelle zum Zielund wieder zurück zu reisenQuelle: wikipedia

BandwidthIn computer networking, bandwidth is a measurement of bit-rate of available or consumed data communication resources expressed in bits per second or multiples of it (bit/s, kbit/s, Mbit/s, Gbit/s, etc.).This is in contrast to the use of the term bandwidth in the field of signal processing to analog signal bandwidth measured in hertz.

Page 11: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

11

Average RTT to Google in 2016 is...

• Worldwide: ~100ms• US: ~50-60ms

Page 12: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

12

Bandwidth doesn't matter (much)It's the latency, dammit!

Page 13: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

13

PLT: latency vs. bandwidth

Average household in US is running on a 20 Mbps+ connection.

Ergo, average consumer in US would not see an improved PLT by upgrading their connection.

0

500

1000

1500

2000

2500

3000

3500

PLT

(ms)

Latency per Bandwith

500

1000

1500

2000

2500

3000

3500

4000

PLT

(ms)

RTT

Page Load Time as RTT Decreases

Page 14: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

14

Mobile, oh Mobile...

Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbpsdownload and up to 1.5Mbps upload with an average latency of 150ms. On the Sprint 3Gnetwork, users can expect to experience average speeds of 600Kbps - 1.4Mbps download and350Kbps - 500Kbps upload with an average latency of 400ms.

500

1000

1500

2000

2500

3000

3500

4000

PLT

(ms)

RTT

Page Load Time as RTT Decreases

We stopped at 240 ms!

Page 15: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

15

Latency is the new Performance Bottleneck

Page 16: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

16

Improving bandwidth is easy ….

Improving latency is expensive... impossible?

• Still lots of unlit fiber• 60% of new capacity through upgrades• "Just lay more cable" ...

• Bounded by the speed of light• We're already within a small constant factor of the maximum• Lay shorter cables!

$ 80.000.000 / ms

Hibernian (2011):New Transatlantic Cable Built to Shave 5 Milliseconds off Stock Trades

Page 17: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

17

Why is latency the problem?Remember that HTTP thing... yeah...

Page 18: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

18

HTTP doesn't have multiplexing!

http request pipelinig

client server

time

open

close

client server

open

close

time

SYN

ACK

SYN-ACK

GET HTML

SYN

SYN-ACK

ACK

GET HTML

Page 19: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

19

HOLB (Head of Line Blocking)

pipelinig http multiplexinghead of line blocking with http/2

client server

open

close

time

client server

open

close

time

If first response takes more time, the following responses are received accordingly

Page 20: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

20

Open multiple TCP connections!!!

http://www.browserscope.org/?category=network (Stand: 2017)

8 connections per host on Desktop6 connections per host on Mobile (recent builds)

So what, what's the big deal?

Page 21: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

21

Open multiple TCP connections!!!

http://www.browserscope.org/?category=network

New York Times: http://www.nytimes.com/ = 10 different hosts137 requests3720 kB data

Page 22: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

22

TCP Congestion Control & Avoidance...

TCP is designed to probe the network to figure out the available capacityTCP Slow Start - feature, not a bug

0

50

100

150

200

250

1 2 3 4 5 6 7 8 9 10 11

Segm

ents

Round trips

Minimum Round Trips to deliver n Segments

71 kB

143 kB

214 kB

285 kB

0123456789

10111213

0 1 2 3 4 5 6

win

dow

siz

e

time (RTT)

Packet Loss (15 packages sent)

Page 23: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

23

HTTP Archive says….

http://httparchive.org/

Analyses for TOP 100 Websites (April 2017)

Page 24: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

24

HTTP Archive says….

1098 kb, 82 requests, ~14kb per request!MOST HTTP TRAFFIC IS COMPOSED OF SMALL, BURSTY, TCP FLOWS

0

50

100

150

200

250

1 2 3 4 5 6 7 8 9 10 11

Segm

ents

Round trips

Minimum Round Trips to deliver n Segments

71 kB

285 kB

3 6 12You are here

1-3 RTT's

Where wewant to be

Page 25: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

25

Example:

428 ms to download 40 kB of data!

That‘s 0,8 Mbit and it won‘t get faster, regardless the size of my pipe(100Mbit)

Page 26: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

26

So, what's a developer to do?Fix HTTP 1.1! Use HTTP/2 in the meantime...

Page 27: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

27

Header Compression …

User-Agent: 109 bytesLanguage: 35 bytesAccept: 74 bytes

typical header sizes of 700-800 bytes overhead is common

Minimum IPv4 + TCP header: 40 bytesMinimum IPv6 + TCP header: 60 bytes

MTU = 1500 (Ethernet)

MSS IPv4 = 1500 – 40 = 1460 bytes

MSS – Header = 700 bytes

Page 28: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

28

HTTP/2 in action

client server

time

● Full request & response multiplexing

● Mechanism for request prioritization

● Many small files? No problem

● Higher TCP window size

● More efficient use of server resources

● TCP Fast-retransmit for faster recovery

Anti-patterns● Domain sharding

Now we need to unshard - doh!

Page 29: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

29

HTTP/2 in a Nutshell

● One TCP connection

● Request = Stream

● Streams are multiplexed

● Streams are prioritized

● Binary framing

● Length-prefixed

● Control frames

● Data frames

Control Frame:+----------------------------------+|C| Version(15bits) | Type(16bits) |+----------------------------------+| Flags (8) | Length (24 bits) |+----------------------------------+| Data |+----------------------------------+

Data Frame:+----------------------------------+|D| Stream-ID (31bits) |+----------------------------------+| Flags (8) | Length (24 bits) |+----------------------------------+| Data |+----------------------------------+

Page 30: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

30

HTTP/2 Server Push

Premise: server can push resources to client

! Concern: but I don't want the data! Stop it!○ Client can cancel SYN_STREAM if it doesn't the resource

! Resource goes into browsers cache (no client API)

Newsflash: we are already using "server push"! Today, we call it "inlining"

! Inlining works for unique resources, bloats pages otherwise

Advanced use case: forward proxy (ala Amazon's Silk)! Proxy has full knowledge of your cache, can intelligently push data to the client

Page 31: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

31

Encrypt all the things!!!

HTTP/2 runs over TLS! Philosophical reasons

! Political reasons

! Pragmatic + deployment reasons - Bing!

Observation: intermediate proxies get in the way

! Some do it intentionally, many unintentionally

! Ex: Antivirus / Packet Inspection / QoS / ...

SDHC / WebSocket: No TLS works.. in 80-90% of cases

! 10% of the time things fail for no discernable reason

! In practice, any large WebService (WS) deployments run as WSS

Page 32: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

32

But isn't TLS slow?

CPU"On our production frontend machines, SSL/TLS accounts forless than 1% of the CPU load, less than 10KB of memory perconnection and less than 2% of network overhead."

- Adam Langley (Google)

Latency! TLS Next Protocol Negotiation

○ Protocol negotiation as part of TLS handshake! TLS False Start

○ reduce the number of RTTS for full handshake from two to one! TLS Fast Start

○ reduce the RTT to zero! Session resume, ...

Page 33: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

33

Who supports HTTP/2?

Server• Apache• nginx• tomcat• node• ...

3rd parties• Twitter• Wordpress• Facebook*• Akamai• ...

All Google properties• Search, GMail, Docs• GAE + SSL users• ...

● Chrome, since forever..○ Chrome on Android + iOS

● Firefox 13+

Page 34: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

34

But wait, there is a gotcha!there is always a gotcha...

Page 35: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

35

HTTP Head of Line Blocking -> TCP Head of Line Blocking

client server

time

TCP: in-order, reliable delivery...what if a packet is lost?

~1~2% packet loss rate• CWND's get chopped• Fast-retransmit helps, but..• HTTP/2 stalls

High RTT links are a problem too• Traffic shaping• ISP's remove dynamic window scaling!

[linux: tracebox]

Something to think about...

Page 36: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

36http://news.netcraft.com

Page 37: 2 …. HTML5 - Coufal2017).pdf · 14 Mobile, oh Mobile... Users of the Sprint 4G network can expect to experience average speeds of 3Mbps to 6Mbps download and up to 1.5Mbps upload

37

Try -> http://www.httpvshttps.com/


Recommended