HTTP2
理解HTTP2协议并研究其在Netty 4中的实现/HTTP/2 引入了一个新的二进制分帧层(Binary Framing)
这里所谓的“层”,指的是位于套接字接口与应用可见的高级 HTTP API 之间一个经过优化的新编码机制:HTTP 的语义(包括各种动词、方法、标头)都不受影响,不同的是传输期间对它们的编码方式变了。 HTTP/1.x 协议以换行符作为纯文本的分隔符,而 HTTP/2 将所有传输的信息分割为更小的消息和帧,并采用二进制格式对它们编码
HTTP/2 通过支持标头字段压缩和在同一连接上 进行多个并发交换,让应用更有效地利用网络资源,减少 感知的延迟时间。具体来说,它可以对同一连接上的请求和响应消息进行交错 发送并为 HTTP 标头字段使用 有效编码。 > HTTP/2 还允许为请求设置优先级,让更重要的请求更快速地完成,从而进一步 提升性能。
出台的协议更有利于网络,因为与 HTTP/1.x 相比,可以使用更少的 TCP 连接。 > 这意味着与其他流的竞争减小,并且连接的持续时间变长,这些特性反过来提高 了可用网络容量的利用率。 最后,HTTP/2 还可以通过使用二进制消息分帧对消息进行更高效 的处理
- Framing(分帧) is a method for wrapping all the important stuff in a way that makes it easy for consumers of the protocol to read, parse, and create.
The HTTP/2 specification defines a stream as "an independent, bidirectional sequence of frames exchanged between the client and server within an HTTP/2 connection 在HTTP / 2连接中在客户端和服务器之间交换的独立的双向帧序列。". You can think of a stream as a series of frames making up an individual HTTP request/response pair on a connection. The Stream Identifier (bytes 6--9 of the frame header) is what indicates which stream a frame belongs to
A stream is created to transport a pair of request/response messages. and HTTP/2 request/response is split into HEADERs and DATA frames.head of line blocking : 队首阻塞,从而造成底层 TCP 连接的效率低下
Multiplexing, full duplex (全双工): HTTP/2 has the capability of serving the multiple request and response at the same time called Multiplexing; HTTP/2 also enables Duplex Streaming, in other words, HTTP/2 allows reading/writing simultaneously, without requiring line turnarounds. Reading and writing events are independent of each other/duplex就是同时in-out
tools for checking http/2: chrome://net-export / https://netlog-viewer.appspot.com