http 2 - s.conf.guru file• data: url - size limit, no cache, base64 overhead • image sprites -...

23
HTTP 2 Ускорение загрузки с HTTP/2 и веб-серверами нового поколения. Григорий Кочанов, 2017

Upload: others

Post on 01-Sep-2019

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

HTTP 2

Ускорение загрузки с HTTP/2 и веб-серверами нового поколения.

Григорий Кочанов, 2017

Page 2: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

HTTP/2, SPDY и QUIC

Page 3: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

TCP 3-way handshake

Page 4: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

HTTPS session start

Page 5: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

Bandwidth VS Latency

Page 6: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

SOLUTIONS

• KEEP-ALIVE • CONTENT COMPILATION • WEB SOCKETS • SPDY • HTTP/2 • QUIC

Page 7: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

HTTP Keep-Alive

Если б мишки были пчёлами, то они бы нипочём, никогда и не подумали, что с keep-alive облом.   “In HTTP/1 74% of our active connections carry just a single transaction - persistent connections just aren't as helpful as we all want. But in HTTP/2 that number plummets to 25%”, - Mozilla Firefox Principal Engineer

Page 8: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

Content merge• Combining CSS and JS in one file

- debug, update, deployment, development != production • data: URL

- size limit, no cache, base64 overhead • Image sprites

- JPEG, manual work • JS and CSS embedding

- no cache,

Page 9: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

Web sockets

• Ground-up protocol and application development

• Scalability

• Firewalls and mobile providers

• Starts with HTTP 1

Page 10: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

SPDY

Head-of-line blocking

Page 11: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

HTTP/2

Page 12: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

QUIC

Page 13: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

FRAMES, STREAMS and PROMISES

Page 14: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

  Traffic prioritization

• Weight-based: Chromium

• Dependency-based: Firefox

Initial-paint time is 1.5 times faster

Type Weight

HTML 256

CSS 220

script 183

image 110

Page 15: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

Server push

Page 16: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

Server push

Page 17: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

Stream reprioritization

Page 18: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

Reprioritization for Chrome

HTTP/1.1 100 Continue Link: </assets/style.css>; rel=preload Link: </assets/jquery.js>; rel=preload

HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8

<!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="/assets/style.css"> <script type="text/javascript" src="/assets/jquery.js"></script>

Page 19: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up
Page 20: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up
Page 21: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up
Page 22: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up
Page 23: HTTP 2 - s.conf.guru file• data: URL - size limit, no cache, base64 overhead • Image sprites - JPEG, manual work • JS and CSS embedding - no cache, Web sockets • Ground-up

References

https://http2.github.io/faq/

https://developers.google.com/web/fundamentals/performance/http2/

https://h2o.examp1e.net

https://nghttp2.org

https://tools.ietf.org/html/rfc7540