19 Şubat 2020 Çarşamba

HTTP/2

HTTP/2 Neden Lazım
Http/1 ile gelen Latency (gecikme) yüzünden lazım

HTTP/1 Pipelining Destekler
Yani bir kaynağı istedikten hemen sonra cevabı beklemeden yeni bir kaynağı isteyebilir. Buna Pipelining deniliyor.

Ancak Pipelining ile Head-of-line (HOL) blocking problem yaşanıyor. Açıklaması şöyle
However, pipelining is NOT perfect. It is still prone to the famous head-of-line (HOL) blocking problem.

HOL blocking problem is a situation that occurs if a single queue of data packets waiting to be transmitted, and the packet at the head of the queue(line) cannot move forward due to congestion, even if the others behind can.
Head-of-line (HOL) Blocking Problem Çözümü
Açıklaması şöyle
Use of Multiple HTTP Connections.
One could also deal with HOL blocking. Assuming that multiple queues exist. In this case six. Most browsers support six connections per domain. Which is still not enough.

This is the reason why many websites serve static assets such as images, CSS, and JS from subdomains. With each subdomain, they get six more connections to play with. This technique is also known as domain sharding.
Ancak domain sharding kullanılsa bile her subdomain için TCP bağlantısı açılması ve bu bağlantının idame edilmesi gerekiyor.

Http/2 Upgrade
Açıklaması şöyle.
The way a browser connects to HTTP/2 is through a URL that looks exactly the same as the URL for HTTP/1, so it doesn't know that it must be HTTP/2 just from looking at the URL. It will try plain cleartext HTTP if it is given a http:// URL. In order for the browser to not try plain HTTP, the URL must be https:// (and then HTTP/2 upgrade will happen through ALPN), ....
TCP
HTTP/2 altta TCP kullanıyor.

Multiplexing - Aynı Bağlantının Farklı Stream'ler İçin Kullanılması
HTTP/1 Multiplexing desteklemezken, HTTP/2 destekliyor. Açıklaması şöyle. Multiplexing aynı bağlantının farklı istekler için tekrar kullanılması demek. Bağlantı tekrar tekrar kurulmadığı için TLS gibi ağır yük getiren şeyler daha verimli oluyor.
Multiplexing allows the reuse of existing connections by creating multiple streams per connection, each able to send a request. Rather than requiring a connection for every request, we could reuse the same connection for many simultaneous requests. The more we reuse connections, the less overhead we have in establishing mTLS sessions with roundtrips, handshaking, and so on.
Benzer bir açıklama şöyle
HTTP/2 improves over HTTP/1.1 and introduced the new feature of ‘Multiplexing’. This allowed sending multiple requests as separate streams to the server over a single connection and the server will send responses over the streams back to the client. This way inter-service communication is now relatively faster.
Multiplexing ile tam ilgisi olmasa bile (sanırım) HTTP/2 ile paralel veri göndermek mümkün. Açıklaması şöyle
Latency Optimization
Latency restricts the performance of the system; hence it is necessary to optimize it. We can reduce it by adopting the following measures:

HTTP/2: We can reduce it by the use of HTTP/2. It allows parallelized transfers and minimizes the round trips from the sender to the receiver, which are highly effective in reducing the latency.
...
Binary Protocol
HTTP/1 Text Protocol kullanırken, HTTP/2 Binary Protocol kullanıyor. Açıklaması şöyle
HTTP/2 uses binary protocol instead, which is more efficient to parse and more compact, less error-prone compared to textual protocols. 
Önceliklendirme
Açıklaması şöyle
- It provides the ability to prioritize one resource over another and hence place it on the response line head.
- It allows for the unsolicited push of representations from servers to clients.
- The request and response headers are compressed.
- Frames are delivered on streams and the DATA frame payload is subject to flow control.
Stream Id
Açıklaması şöyle
Stream identifiers cannot be reused. Long-lived connections can result in an endpoint exhausting the available range of stream identifiers. A client that is unable to establish a new stream identifier can establish a new connection for new streams. A server that is unable to establish a new stream identifier can send a GOAWAY frame so that the client is forced to open a new connection for new streams.

Hiç yorum yok:

Yorum Gönder