腾讯高级工程师罗成 - 《WEB加速,协议先行》

苌笑柳

2017/11/14 发布于 技术 分类

访问 Web 网站和应用时,经常会遇到各种各样的性能问题。比如网页加载慢、视频卡、网络出错等,其中一个关键的影响因素就是网络协议。 本次演讲会系统化地介绍 TCP、UDP、HTTP1.1、HTTPS(包括最新的 TLS1.3协议)、SPDY、HTTP2 等协议存在的问题,以及如何在特定的场景下通过网络协议的优化实现访问速度的提升。

文字内容
1. WEB‫ے‬᭛ ‫ضᦓܐ‬ᤈ ᗔ౮ ᚸᦔṛᕆૡᑕ૵
4. ӻՈᓌՕ 2011 ླӱ ၭ࿯ य़਍ ● ഴ‫ګ‬ᔮ ■ ਫ෸ᔮᕹ 20112015 ጯଶ ● ᬩᖌ᮱ ■ ෈կ‫ݎړ‬ ■ ᕹӞള‫ف‬ ■ ਞ‫ق‬൤ᔱ 2015NOW ᚸᦔ ● चᏐຝ຅᮱ ■ STGW/ᚸᦔ ԯCLB ■ ᨮ᫹࣐ᤍ ■ ‫ᦓܐ‬ս۸
5. ᦢᳯWebᕪଉ᭬‫ک‬ጱᳯ᷌
6. ୽ߥWEB௔ᚆጱԆᥝࢩᔰ ᗑᕶ ‫ᦓܐ‬ ᗑᕶ ᶭᶎ ሾह WEB य़ੜ ௔ᚆ ᒒᯈᗝ ᶭᶎ ‫ز‬ᔰ
7. Ӟ๵HTTP2 ᧗࿢ᕪᬦጱ‫ᦓܐ‬຾ EFI H H ./ CH 1 LH . H2 H ./ H ਮಁᒒ‫ݢ‬ഴ 1 CH . LH L2 H
8. HTTP1.1ጱ௔ᚆᳯ᷌ ● ‫ܔ‬᱾ളԀᤈ ➢ පሲ֗ӥ ● १᮱๚ܴᖽ ➢ ٞ֟ ➢ Ӥӥᤈଃ਼ӧ੒ᑍ ➢ १᮱ଘ࣐य़ੜ᩻ᬦ 1500B ● ASCIIก෈ ➢ ᥴຉౌ 2 4 5= 33 21 22 .= 2 4 5= 33 21 22 .= 2 4 5= 33 21 22 .=
9. HTTP1.1ጱս۸---ी‫ے‬ᬳള҅‫ٺ‬੝᧗࿢ pipelining 54 . 1 333 . .. 2 . 1 333 .. 2 . . 1 333 . .. 2 . ٌ՜WEBս۸ᒽኼ • ᖨਂ • CSS Sprites • data uri, Inline Images
10. HTTPS/HTTP2‫ے‬᭛HTTP1.1ጱႣ࿶ ● ‫ق‬ᒊHTTPSள᭛ฦ݊ ➢ 46%ጱᗑᒊඪ೮HTTPS ● HTTP2 Ⴙ౮Ԇၞ ➢ 2015.5 ‫૲ݎ‬ ➢ 2017.05ֵ҅አሲ13.7% ● ṛᬳള౮๜+ग़᪠॔አ+server push ➢ HTTP1.1ս۸ᒽኼ०ප
11. HTTP vs HTTPSᬳള౮๜ + + . . /1 + HTTP1.1᧗࿢ AC + O P H1 H1 3 0+ K 0+ L N S 2 D 2 A HTTPS᧗࿢
12. ๚ᕪս۸ጱHTTPS᭛ଶกดౌԭHTTP ● ᗑᕶᘙ෸ ➢ ๋ࣕఘ‫٭‬ӥी‫ے‬7ӻRTT ➢ 500msզӤ ● ᦇᓒᘙ෸ ➢ ਮಁᒒ҅50msզӤ ◆ ᦤԡ໊ḵ̵ੂᰬԻഘ ➢ ๐‫ۓ‬ᒒ҅15msզӤ RTT݇ᘍ꧊ 400 300 200 100 0 ‫֖ܔ‬:ms WIFI 4G 3G 2G
13. HTTPS = HTTP + SLOW ?
14. Why SlowҘᕚӥཛྷ೙ၥᦶ ● ᛔۖ۸ ● ၾᴻ᧏૧ - ‫҅ྲݶ‬ሾྲ҅10000๵ ● ૡٍ - Chrome Remote debug - Linux traffic control - performance timing api
15. Why SlowҘᕚӤӱ‫ۓ‬᭛ଶහഝ᯻ᵞ ● ๐‫ۓ‬ᒒ᯻ᵞս۠ - ବ੶‫௳מ‬ӿ੄҅ RTT҅ ‫ᦓܐ‬ᇇ๜҅ᬳള‫҅௳מ‬ session҅ੂᎱॺկ҅ൎ ಋ෸ᳵ҅१᮱ܴᖽྲ - ᪜ଘ‫ݎ୏҅ݣ‬౮๜֗ C G
16. Why SlowҘग़ᖌහഝ‫ړ‬ຉ item start_load css_load js_load dom_ready active req_time tcp_reuse TLSv1.2 tcp_first_use ecdhe-rsa-aes128gcm-sha256 android_wifi_spdy_tcp _first_use android5_tcp_first_use (http) ios8_tcp_reuse(http) 705 966 1422 975 1574 999 349 719 982 1430 994 1594 1046 382 1541 1982 2856 1973 2924 2048 737 858 1132 1618 1140 1772 1217 441 2120 2591 3594 2568 3618 2461 893 147 165 138 163 147 86 100 ᚸᦔX5ٖ໐ၨᥦ࢏ࣁ4GᗑᕶӥֵአHTTP2ଚӬฎTLS1.2‫ᦓܐ‬ଚ ӬֵአECDHEଚӬဌํ॔አtls sessionጱḒ੽෸ᳵฎग़੝Ҙ
17. WEBᦢᳯ᭛ଶս۸ො‫ݻ‬ ● ‫ᦓܐ‬ ➢ TCP҅TLS҅HTTP2 ● ᩒრ ➢ CDN҅ऒ‫҅ݷ‬ᶭᶎ‫ز‬ᔰ ● አಁᤈԅ ➢ ᶼୌᬳള
18. TCP᭛ଶս۸ ● TFO(tcp fast open) ➢ 80‫֖ړ‬487ms->390ms ➢ iOS9+, kernel v3.7+ ● ೜लഴ‫ګ‬ ➢ ीय़೜लᑻ‫ ݗ‬3 ->10 ➢ BBR ● ս۸౮๜ṛ ➢ ᵱᥝ඙֢ᔮᕹඪ೮ + 2 2 ฦ᭗ൎಋ TFO + 2 + 2 + +
19. TLS᭛ଶս۸—session resumption Session id Session ticket ClientHello Session ID Session Cache ID ClientHello Sessoin ticket Session ticket iOS Qzone SSLൎಋ෸ᳵғ 200ms -> 100ms ൉‫܋‬50% iOS ӧඪ೮
20. TLS᭛ଶս۸---False Start ฦ᭗ൎಋ False Start ඪ೮Perfect Forward Secret ECDHE҅DHE SSL ൎಋ෸ᳵ൉‫܋‬30%
21. TLS᭛ଶս۸---OCSP Stapling OCSP OCSP Stapling ਮಁᒒᖨਂ7ॠ
22. TLS᭛ଶս۸---dynamic record size • ܻࢩ - recordฎTLS॒ቘጱ ๋ੜ‫֖ܔ‬ • ᥴ٬ොໜ - ssl_buffer_size 4k - patch TLS head of line blocking
23. TLS1.3᭛ଶս۸---0RTT Handshake TLS1.3 1RTT full handshake TLS 0RTT Preshared Key ● TLS1.3 ᶼᦇԭՔଙᐾਊྋୗ‫૲ݎ‬ ● Openssl 1.1.1҅Nginx 1.13.0ඪ೮draft 20
24. HTTPS᭛ଶս۸---HSTS‫ٺ‬੝302᪡᫨ ਮಁᒒ ● HTTP Strict Transport Security(HSTS) ➢ Strict-Transport-Security: maxage=0; includeSubDomains ● Preload list ➢ https:// hstspreload.appspot.com HTTP HTTP 307ٖ᮱᪡᫨ HTTPS ๐‫ۓ‬ᒒ HSTS
25. HTTPS᭛ଶս۸---SPDY && HTTP2 • ԫᬰ‫ګ‬ • ग़᪠॔አ - ‫ܔ‬ӻᬳള҅ग़ ӻ᧗࿢ • ս‫ض‬ᕆ ਮಁᒒ ๐‫ۓ‬ᒒ ਮಁᒒ ๐‫ۓ‬ᒒ ग़᪠॔አ pipelining
26. HTTPS᭛ଶս۸—SPDY&&HTTP2 • १᮱ܴᖽ - 90%ܴᖽሲ • Server push - ๚‫ضݎ‬ᛗ ਮಁᒒ ๐‫ۓ‬ᒒ html css png
27. HTTP2ਫ᪢ୌᦓ ● ֵአӞӻᬳള ✦ ൎಋ੝ܴ҅ᖽṛ҅ๅঅࣈ‫ڥ‬አTCPᇙ௔ ● ֵአๅ੝ጱऒ‫ݷ‬ ✦ ‫ٺ‬੝DNSᥴຉ෸ᳵ ● ग़ऒ‫॔ݷ‬አፘ‫ݶ‬IP҅ፘ‫ᦤݶ‬ԡ ✦ ॔አᬳള ● ᅎၚᬩአserver push҅դ๊inlining ● ֵአTLS1.2 ● HTTP2ᭇአԭग़‫ز‬ᔰ࣋ว
28. WEB᭛ଶս۸---ᶼୌᬳള ● ᶼୌᬳളᜓ፜ 400msզӤ - link ຽᓋ޾१᮱ - Ḓᶭ൉‫ڹ‬ᶼୌৼᶭᶎᬳള - አಁᤈԅᶼၥ ● ᳩᬳളᖌ೮ - stgw_precon.html - ‫ݣݸ‬JSᑁᕆ‫ڦ‬ᖌ೮ᳩᬳള
29. HTTPSᦢᳯ᭛ଶᚆड़᩻᩼HTTP1.1
30. HTTP2ฎ๚๶‫ހ‬Ҙ ฎѺ ● ग़᪠॔አ ● १᮱ܴᖽ ● server push ● ս‫ض‬ᕆ ӧฎѺ ● TCPӣེൎಋ+TLSൎಋ ● TCP१ᓫද ● Head of line blocking ● ᯿փ ● ೜लഴ‫ګ‬
31. ೜಼QUIC HTTP2ᇙ௔ + TLS1.3 ൎಋ + UDPփᬌ + चԭ packetጱ‫ੂے‬
32. ཻᬨ֛ḵᚸᦔԯ + CLBᨮ᫹࣐ᤍ
33. ཻᬨ‫ဳى‬ “ᚸᦔຝ຅૵” ᎣԒIDғhelloworlds ங‫ܗ‬IDғ԰ᘶᗑᗔ౮ ᎣԒӫໄ: HTTPSܻቘ޾ਫ᪢