Pages

Sunday, January 28, 2024

HTTP/1 vs HTTP/1.1 vs HTTP/2 vs HTTP/3

HTTP/1 came out in 1996. It is built on top of TCP. Every request to the same server requires a separate TCP connection. 

HTTP/1.1 came out soon in 1997. It introduce a keep alive mechanism, so a connection could be reuse for more than a single request. The persistent connections reduce request latency, because the client does not need to initiate expensive three way handshake for every request. It's worthwhile to note that HTTP/1.1 also added HTTP pipelining. This in theory allows client to send multiple requests before waiting for each response. The response must be received in the same order as to requests. It was tricky to implement correctly and many proxy server in between did not handle pipelining properly. Its support was eventually removed from many web browsers. HTTP/1.1 with pipelining also suffers from an issue call head of line blocking. Without align blocking subsequent request on the same connection must wait for the previous requests to complete. If a request is blocked for any reason like packet loss, all subsequent requests on the same connection are also impacted. To keep loading performance at an acceptance level browsers normally keep multiple TCP connections to the same server and send requests to it in parallel. 

HTTP/2 was published in 2015. HTTP/2 introduce HTTP streams. where multiple streams of request could be sent to the same server on a single TCP connection. Unlike HTTP/1.1 pipelining, each stream is independent of each other and it does not need to be send and receive in order. HTTP/2 solves the head line blocking issue at the application layer but the issue still exists in the transport layer with TCP. Also note that HTTP/2 introduce a push capability to allow servers to send updates to the client whenever new data is available without requiring a client to poll. 

HTTP/3 begin as draft in 2020 and has recently been published in late June 2022. It uses a new protocol called QUIC instead of TCP as the underlying transport protocol. QUIC is based on UDP. It introduces streams as a first class citizen at transport layer. QUIC streams share the same quick connection so no additional handshake are required to create new ones. QUIC streams are delivered independently. In most cases packet loss affecting one stream doesn't affect others. This is how QUIC eliminates the head of line blocking at the transport layer. QUIC is designed for mobile heavy internet usage. People carrying smart phones switch frequently from one network to another as they move about their day. With TCP, the handoff of one connection from one network to another is sluggish. QUIC implements a concept of connection ID, which allows a connection to move between IP addresses and network interfaces quickly and reliably. Even though HTTP/3 is just standardized, it is used by 25% of the web sites and supported by many web browsers. 

HTTP (Hypertext Transfer Protocol) is the foundation of data communication on the World Wide Web. Over time, several versions of HTTP have been developed, each with improvements and new features. Here's a comparison of HTTP/1, HTTP/1.1, HTTP/2, and HTTP/3:

1. **HTTP/1.0**:

   - Released in 1996, HTTP/1.0 was the first version of the HTTP protocol widely adopted for web communication.

   - It is a simple and straightforward protocol, but it has limitations in terms of performance and efficiency.

   - Each request/response in HTTP/1.0 requires a separate TCP connection, leading to high latency and overhead, especially for loading multiple resources on a web page.

   - There is no support for persistent connections or request pipelining in HTTP/1.0, which further contributes to performance issues.


2. **HTTP/1.1**:

   - Released in 1999, HTTP/1.1 introduced several improvements over HTTP/1.0 to address performance issues and enhance efficiency.

   - Persistent Connections: HTTP/1.1 introduced the concept of persistent connections, allowing multiple requests and responses to be sent over the same TCP connection. This reduces latency and overhead by avoiding the need to establish a new connection for each request.

   - Request Pipelining: HTTP/1.1 supports request pipelining, allowing multiple requests to be sent over the same connection without waiting for each response. However, pipelining has limitations and can lead to head-of-line blocking issues.

   - Chunked Transfer Encoding: HTTP/1.1 introduced chunked transfer encoding, which allows data to be sent in chunks, enabling streaming and progressive rendering of large responses.

   - Host Header: HTTP/1.1 introduced the Host header, allowing multiple websites to be hosted on the same IP address, improving server efficiency and scalability.


3. **HTTP/2**:

   - Released in 2015, HTTP/2 is a major revision of the HTTP protocol designed to improve performance, efficiency, and security.

   - Binary Protocol: HTTP/2 uses a binary framing layer instead of the text-based protocol of HTTP/1.x, which reduces parsing overhead and improves efficiency.

   - Multiplexing: HTTP/2 supports multiplexing, allowing multiple requests and responses to be sent over the same TCP connection simultaneously. This reduces latency and improves resource utilization.

   - Header Compression: HTTP/2 uses header compression techniques to reduce the size of header fields, further improving efficiency and reducing overhead.

   - Server Push: HTTP/2 introduces server push, which allows the server to push additional resources to the client before they are requested, improving page load times and reducing latency.

   - Stream Prioritization: HTTP/2 supports stream prioritization, allowing clients to prioritize requests and responses based on their importance, which improves the overall user experience.

4. **HTTP/3**:

   - HTTP/3, also known as QUIC (Quick UDP Internet Connections), is the latest version of the HTTP protocol currently under development.

   - UDP-Based Protocol: HTTP/3 is built on top of the QUIC transport protocol, which uses UDP instead of TCP. This reduces latency and improves performance by avoiding TCP connection setup and congestion control mechanisms.

   - Multiplexing and Encryption: HTTP/3 retains the multiplexing and encryption features of HTTP/2 but operates over QUIC, which provides better support for multiplexing and improved security.

   - Connection Migration: HTTP/3 supports connection migration, allowing the client to switch between network interfaces (e.g., Wi-Fi to cellular) without interrupting ongoing requests, improving resilience and reliability.

   - Forward Error Correction: HTTP/3 incorporates forward error correction techniques to recover lost packets and reduce retransmissions, improving reliability and performance in unreliable network environments.


Overall, HTTP/2 and HTTP/3 represent significant advancements in web protocol design, offering improved performance, efficiency, and security compared to earlier versions of HTTP. As the web continues to evolve, HTTP/3 is expected to become the new standard for web communication, further enhancing the user experience and enabling new use cases for web applications and services.


No comments:

Post a Comment