Need cloud computing? Get started now

How HTTP/2 Persistent Connections Help Improve Performance and User Experience

Akamai Wave Blue

Written by

Mihai Puchiu, Santanu Pathak, and Julio Chaves Herrera

April 23, 2024

Mihai Puchiu

Written by

Mihai Puchiu

Mihai Puchiu is a Senior Product Manager for Core Network Performance and Reliability at Akamai. Mihai has more than 20 years of experience in internet and media technologies. He is enthusiastic about developing and introducing innovative solutions to the market. Outside of work, Mihai enjoys hiking and connecting with nature.

Santanu Pathak

Written by

Santanu Pathak

Santanu Pathak is a product manager for Core Network Performance and Reliability at Akamai. Santanu has more than 20 years of experience in internet and media technologies. He is enthusiastic about developing and introducing innovative solutions to the market. Outside of work, Santanu enjoys building new applications using the latest technologies.

Julio Chaves Herrera is a product marketer at Akamai. Julio has spent over five years infusing creativity across product messaging, corporate events, and communications. He works directly with Akamai’s product management, engineering, and sales teams, and is focused on developing go-to-market strategies that keep Akamai products relevant in everyone's mind. Outside of work, Julio enjoys playing video games.

With improved persistent connection, fewer HTTP requests required a DNS request, and the number of requests with DNS latency decreased by approximately 33%.
With improved persistent connection, fewer HTTP requests required a DNS request, and the number of requests with DNS latency decreased by approximately 33%.

HTTP/2 is the second hypertext transfer protocol (HTTP) specification based on the obsolete SPDY communication protocol. The introduction of HTTP/2 to web browsers by the Internet Engineering Task Force (IETF) brought several significant enhancements over its predecessor that improved performance bottlenecks, efficiency, speed, and the security of data transmission over the World Wide Web.

The transition from HTTP/1.1 to HTTP/2 introduced persistent connections, a notable evolution in how connections are handled that represents one of the key HTTP/2 features for managing client-server connections. These persistent connections existed in HTTP/1.0, but were refined and optimized by HTTP/2.

What is a persistent connection?

As detailed in RFC 7540, HTTP/2 persistent connections are a foundational change aimed at addressing the HTTP/1.x header’s performance limitations.

HTTP/2 significantly improves the efficiency, round-trip times, and reliability of web communications by allowing multiple requests and responses to be multiplexed over a single connection. This approach inherently relies on persistent connections to allow multiple streams — individual requests — to be in flight simultaneously.

As noted earlier, HTTP/2 optimized the persistent connections that were already present in the first HTTP version. As a result, both metadata and data — including plaintext, HTML, CSS, JavaScript, status codes, and HTTP headers containing header fields — can be transmitted over networks more securely and with far less network latency thanks to improved encoding techniques, like binary protocol, that use less bandwidth.

Managing HTTP/2 persistent connections involves several mechanisms that indirectly relate to how timeouts could be handled with stream prioritization, flow control, connection precedence, and dependencies methods. Although HTTP/2 focuses on efficient use, reuse, and management of persistent connections, it doesn’t specify exact timeout values. Rather, HTTP/2 expects long-lived connections that facilitate efficient multiplexing, delegating to implementation details how idle connections and timeouts are handled.

Persistent connection timeouts

Persistent connection timeouts consume significant web server-side resources in web infrastructure applications. These nuanced effects can vary based on the specific application architecture, server configuration, and the nature of client interactions.

Benefits of persistent connections

  • Persistent connections reduce the need to frequently establish and remove Transmission Control Protocol (TCP) connections by keeping connections open and serving multiple requests from a single TCP connection to improve resource efficiency.

  • Persistent connections improve network efficiency, throughput, and latency with connections that minimize time spent on connection setups.

Challenges of persistent connections

  • High-persistence connection timeouts can increase memory use, which can affect the server's ability to handle new connections.

  • Long timeouts can saturate connection slots, which can impact new connections and degrade service availability and responsiveness.

  • Long timeouts can lock or reserve resources, which can reduce the server efficiency needed to effectively serve other requests. Attackers can open and keep connections alive with minimal activity to exhaust server resources.

To mitigate the impact of these persistent connection challenges and maximize the benefits, servers must adopt intelligent connection and resource management strategies. These include:

  • Adjusting connection timeout values based on current server load and resource availability

  • Implementing connection pooling to more efficiently manage all open connections

  • Actively monitoring resource use and implementing autoscaling policies to help effectively manage loads

  • Implementing security measures like rate limiting, connection throttling, and intrusion detection systems to detect and mitigate potential denial-of-service (DoS) attacks

Akamai’s approach to persistent connections

To improve user experience, Akamai increased the HTTP/2 persistent connection timeout, thereby reducing the number of Transport Layer Security (TLS) handshakes. We then further enhanced HTTP/2 performance by implementing a significant optimization to our approach to memory use.

These enhancements enable servers to maintain more simultaneous persistent connections, which reduces the need to frequently reestablish connections and boosts overall efficiency. We also extended persistent connection timeouts to two minutes across our network to improve performance.

The A/B tests performed during this feature’s rollout revealed a drop in new TCP connections with HTTP/2 — a 22% relative improvement — and an overall increase in HTTP requests (Figure 1).

The A/B tests performed during this feature’s rollout revealed a drop in new TCP connections with HTTP/2 — a 22% relative improvement — and an overall increase in HTTP requests (Figure 1). Fig. 1: Before-and-after comparison of new TCP connections for HTTP/2 requests after persistent connection efforts

In addition, these persistent connection improvements reduced the number of HTTP/2 requests that experience TLS (formerly SSL) overhead, aligning with the decrease in new TCP connections. As a result, requests with TLS overhead that exceeds 50 milliseconds decreased by 20%, while the percentage with TLS overhead that exceeds 20 milliseconds dropped by approximately 19% for all HTTP/2 requests and by about 50% for HTTP/2 API requests.

With improved persistent connection, fewer HTTP requests required a DNS request, and the number of requests with DNS latency decreased by approximately 33%.

Performance benefits for users

Our end users directly benefit from longer persistent connection timeouts. Figure 2 displays client-side data observed with Akamai mPulse — the real user monitoring solution that helps companies better understand end user site experiences — revealing a 10% improvement to First Contentful Paint (FCP).

Figure 2 displays client-side data observed with Akamai mPulse — the real user monitoring solution that helps companies better understand end user site experiences — revealing a 10% improvement to First Contentful Paint (FCP). Fig. 2: Before-and-after comparison of FCP after persistent connection efforts on the Akamai network

FCP is a metric that measures when the first piece of content, such as text, an image, or any other visible element, is rendered on a web page. FCP is important because it indicates to users that the page is actually loading and provides feedback on its responsiveness. For more insights on FCP and other SEO-friendly performance metrics, read part two of our five-part series on improving your website’s page load times with performance engineering.

Although FCP isn’t officially classified as a Core Web Vital (CWV) metric, it significantly influences the Largest Contentful Paint (LCP), which is a critical CWV that measures how long it takes for a web page’s main content to load. Faster FCPs improve loading times and LCP scores, which enhance overall user experience.

Effective persistent connection strategies

CDN customers should be aware that persistent connection timeout settings are customizable in some cases, and increasing these messages isn’t always beneficial. It’s also important to avoid connection saturation, optimize memory consumption, manage the cost of serving end users, and protect both end users and CDN customers from distributed denial-of-service (DDoS) vulnerabilities.

Akamai provides additional information on persistent connections between the ​Akamai​ edge and origin servers. These connections, opened by the clients, improve performance and optimize server resource utilization.

Summary

At Akamai, we’re committed to providing our customers with the best experience possible. In 2023, we made significant improvements to enhance customer experience by optimizing memory use and extending the persistent connection timeout for HTTP/2.

These changes resulted in:

  • A 20% drop in requests with TLS overheads larger than 50 milliseconds 

  • An approximately 19% drop in HTTP/2 requests with TLS overheads greater than 20 milliseconds and an approximately 50% drop in HTTP/2 API requests 

  • A decrease of approximately 33% in the average DNS latency

  • A roughly 10% FCP improvement in client-side data observed with mPulse

Learn more

Check out our TechDocs to get HTTP/2 performance tips and best practices — or contact the Akamai support team for further assistance.



Akamai Wave Blue

Written by

Mihai Puchiu, Santanu Pathak, and Julio Chaves Herrera

April 23, 2024

Mihai Puchiu

Written by

Mihai Puchiu

Mihai Puchiu is a Senior Product Manager for Core Network Performance and Reliability at Akamai. Mihai has more than 20 years of experience in internet and media technologies. He is enthusiastic about developing and introducing innovative solutions to the market. Outside of work, Mihai enjoys hiking and connecting with nature.

Santanu Pathak

Written by

Santanu Pathak

Santanu Pathak is a product manager for Core Network Performance and Reliability at Akamai. Santanu has more than 20 years of experience in internet and media technologies. He is enthusiastic about developing and introducing innovative solutions to the market. Outside of work, Santanu enjoys building new applications using the latest technologies.

Julio Chaves Herrera is a product marketer at Akamai. Julio has spent over five years infusing creativity across product messaging, corporate events, and communications. He works directly with Akamai’s product management, engineering, and sales teams, and is focused on developing go-to-market strategies that keep Akamai products relevant in everyone's mind. Outside of work, Julio enjoys playing video games.