From d7a38e83ca223bc6c1219635a38f91893c07cc34 Mon Sep 17 00:00:00 2001 From: leafee98 Date: Mon, 30 May 2022 11:43:59 +0800 Subject: [PATCH] new essay: why upload with http2 slower than http1.1 --- ...y-upload-with-http2-slower-than-http1.1.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 content/essays/why-upload-with-http2-slower-than-http1.1.md diff --git a/content/essays/why-upload-with-http2-slower-than-http1.1.md b/content/essays/why-upload-with-http2-slower-than-http1.1.md new file mode 100644 index 0000000..bf23e11 --- /dev/null +++ b/content/essays/why-upload-with-http2-slower-than-http1.1.md @@ -0,0 +1,19 @@ +--- +title: "HTTP/2 的上传速度表现劣于 HTTP/1.1 的原因" +date: 2022-05-30T09:29:51+08:00 +tags: [] +categories: [] +weight: 50 +show_comments: true +draft: false +--- + + + +在使用 Nginx 提供的 HTTP/2 实现时,有些情况下会发现上传速度不理想,甚至慢于 HTTP/1.1,这是因为 HTTP/2 相较于 HTTP/1.1 多了一个在应用层的流传输控制。 + +HTTP/2 和 HTTP/1.1 共同基于的 TCP 也拥有流控制,TCP 的流控制的窗口大小由操作系统决定,并且影响操作系统建立的所有 TCP 连接的速率上限,此上限亦即 HTTP/1.1 的速率上限;HTTP/2 的流控制的窗口大小由对应软件如 Nginx 实现,当此窗口小于 TCP 的窗口并且具有一定的差距时,HTTP/2 的速率会受到明显影响,另一方面当 HTTP/2 的流控制窗口过大时,又会造成内存的浪费,当设定为某一个合适的值时,性能表现甚至会略微胜过 HTTP/1.1。 + +## 参考 + +[Delivering HTTP/2 upload speed improvements](https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/)