Post

Understanding the need of HTTP/3

Hey Folks!

We have been using HTTP and it versions in our day to day life but, do we know what are the differences between different versions of HTTP?

In this article, we will walkthough from basics like

  • What is HTTP?
  • How does a HTTP request and response appear?
  • What are its versions?
  • What are the features of each version?
  • What was the requirement to upgrade?

Let’s begin!

What is HTTP?

HTTP(Hyper Text Transfer Protocol) is the basis of data transfer or communcation for the World Wide Web(WWW). Simply, It is an application layer protocol that enables the user to access resources on Internet.

HTTP operates as request-response protocol in client-server architecture. A user initiates a request through web browser as a client while a web server responds to the request as a server. It helps exchange of data for instance multimedia and HTML betwwen client and a server on port 80.

A sample HTTP Request

Following is a sample request to a local server running on port 4000 from browser

1
2
3
4
5
6
7
8
9
10
GET / HTTP/1.1
Host: localhost:4000
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cache-Control: max-age=0
Connection: keep-alive
signed-exchange;v=b3;q=0.7
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

A sample HTTP Response

Following is a response to above request

1
2
3
4
5
6
7
8
9
HTTP/1.1 200 OK
Cache-Control: private, max-age=0, proxy-revalidate, no-store, no-cache, must-revalidate
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
Content-Length: 41150
Date: Sun, 09 Jul 2023 03:35:57 GMT
Etag: 2976a15-a0be-64aa2b14
Last-Modified: Sun, 09 Jul 2023 03:35:48 GMT
Server: WEBrick/1.8.1 (Ruby/3.2.2/2023-03-30)

Different versions of HTTP

The development of HTTP was started at CERN in 1989 with a simple document expalining the client and server using HTTP 0.9. HTTP have evolved over the years and several versions are:

VersionRelease Year
HTTP/0.91991
HTTP/1.01996
HTTP/1.11997
HTTP/22015
HTTP/32022

HTTP/1.0

HTTP/1.0 was released in 1996 as final HTTP/1.0 revision. It is a stateless application level protocol for distributive, collaborative, hypertext information systems. Here stateless means that the each request and response are not dependent on each other. This was built on top of TCP connection to communicate(HTTP over TCP).

A separate TCP connective was required for each client and server communication. It was a major issue as everytime a seperate TCP call was required for exchange.

Let’s see an example to understand deeper:

HTTP/1.0

HTTP/1.1

HTTP/1.1 was released in 1997 with a concept of a keep-alive. This was introduced for having a connection which could be resused for more than one request or response.

HTTP/1.1 without pipeline

A few benefits of this version:

  • Reduced Request Latency: The persistent connection reduced latency because the client didn’t have to re-negotiate the TCP Handshake connection post first request.

  • Faster connection: The connection became generally faster with time due to TCP;s slow-start mechanism.

  • Pipelining: To reduce more lag time while using a persistent connection, clients were allowed to send multiple requests before waiting for each response.

    HTTP/1.1 with pipeline

Demerits:

  • Pipelining: This was too difficult to achieve because a few web and proxy servers on Internet between the client and server could not handle request pipeline correctly.

  • HOL: Head-of-line Blocking is when there are too many parallel requests in web browser and subsequent requests required to hold for the previous ones to finish. HTTP required responses to be sent in order of which requests were recieved and if any one requests takes longer to respond the server could not process other requests until the former was finished over a single TCP connection.

    HTTP/1.1 HOL

For example, A page needs to load more resources such as HTML, Images, JavaScript, CSS to be called complete. A typical browser these days can open upto 6 TCP connections(Please check the updated number). Following gives an example of how a browser opens a single TCP connection and push another only when former is completed in HTTP/1.1.

HTTP/1.1 Inpect Element Network Waterfall

In above, the total time to complete the cycle is 280ms, first DNS Lookup finishes then Socket Connection later, HTTP Request and at last, Content is served.

HTTP/2

HTTP/2, the successor to HTTP/1.1, has brought about significant advancements in web communication. By addressing performance issues and enhancing security, HTTP/2 has revolutionized the way we experience the web, delivering faster and more secure interactions. It is used by 39% of websites and supported by most of the browsers as of April 2023. Moreover, it is supported by major webservers with TLS and over 97% of users.

A few benefits of this version and issues it resolved:

  • Multiplexing: HTTP/2 eliminates the requirement for multiple connections by allowing simultaneous requests and responses over a single connection, cutting down on latency. This is also known as streams. Each stream represents an independent, bi-directional sequence of frames that carries a specific request-response transaction between the client and server. Overall performance is enhanced because it overcomes the head-of-line blocking problem, in which a sluggish request prevents faster ones from being processed.

    An example of how streams can be utilised:

    • The client establishes a TCP connection with the server and initiates the HTTP/2 protocol.
    • The client sends a request to the server for a webpage that includes multiple resources such as HTML, CSS, and images.
    • The server receives the request and assigns a unique identifier (stream ID) to the request.
    • The server begins processing the request and starts sending the corresponding response frames back to the client within the same stream.
    • While the server is processing the initial request, the client can initiate additional requests for other resources by opening new streams within the same TCP connection. These additional requests can be sent concurrently. The server can prioritize the streams based on importance, allowing critical resources to be delivered first.
    • As the server completes processing each stream, it sends the corresponding response frames back to the client.
    • The client receives the response frames for each stream and can render the webpage progressively as the resources become available.

      HTTP/2 Streams

  • Header Compression: HTTP/2 uses header compression methods to minimise the amount of header data that is sent back and forth between the client and the server. This reduces bandwidth usage, increases effectiveness, and hastens the loading of web pages.

  • Server Push: It enables servers to transfer resources to clients without waiting for explicit requests. This eliminates the need for subsequent round trips, reducing latency and further improving page load speed.

  • Binary Protocol: HTTP/2 uses a binary protocol instead of plain text, making it more efficient for parsing and processing by both clients and servers. This enhances overall performance and reduces processing overhead.

  • Prioritization: It enables priority settings for requests, enabling more critical resources to be processed and delivered first. This improves the rendering of web pages, ensuring important content is prioritized.

  • Secure by Default: It mandates the use of Transport Layer Security (TLS), providing encryption and ensuring secure communication between the client and server. It addresses the issue of data interception, improves privacy and security for users.

  • Backward Compatibility: It is designed to be backward compatible with HTTP/1.1, enabling seamless communication between older clients and servers. This allows websites to adopt HTTP/2 gradually without disrupting existing infrastructure.

The only prime drawback is increased memory usage compared to HTTP/1.1 due to multiplexing for devices with limited resources.

HTTP/3

HTTP/3 is the latest major version of HTTP released in 2022 and is based on the QUIC (Quick UDP Internet Connections) transport protocol. It is designed to address some of the limitations and challenges of its predecessors, HTTP/1.1 and HTTP/2.

Benefits of HTTP/3:

  • Improved Performance: It offers enhanced performance by leveraging the QUIC transport protocol. QUIC operates over the User Datagram Protocol (UDP) instead of TCP, reducing connection establishment latency and providing better congestion control. This results in faster and more efficient data transmission, especially in scenarios with high packet loss or unreliable networks.

  • Reduced Latency and Faster Page Load Times: The QUIC protocol incorporates features like 0-RTT (zero round-trip time) handshakes, enabling faster connection establishment. Additionally, multiplexing and stream prioritization in HTTP/3 enhance parallelism, reducing latency and facilitating quicker page load times.

  • Enhanced Security: It includes encryption as a mandatory requirement, similar to HTTP/2. The encryption provided by QUIC ensures the confidentiality and integrity of data exchanged between the client and server. This security feature is particularly crucial in today’s privacy-conscious and security-aware online environment.

  • Improved Congestion Control: QUIC’s congestion control mechanisms are designed to adapt to network conditions more effectively than TCP, reducing packet loss and improving overall network performance. This enables better bandwidth utilization and a more consistent user experience.

  • Better Network Connectivity Resilience: HTTP/3’s use of QUIC over UDP allows for improved network connectivity resilience. QUIC’s ability to seamlessly switch between network interfaces, such as Wi-Fi and cellular networks, minimizes interruptions and maintains connectivity during network handoffs or transitions.

    HTTP/3 UDP QUIC

In theory, HTTP/3 works fine but still adoption is required by many networks and browsers.

Differences in protocol layers stack

HTTP Protocol Stack

Please have a look at requests in network tab under inspect element or dev tools for interesting stuff related to HTTP requests and responses.

Thanks!

References:

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.