Browse Definitions :
Definition

persistent connection

What is a persistent connection?

A persistent connection, also known as a Hypertext Transfer Protocol (HTTP) persistent connection, refers to a network communication channel that remains open for further HTTP requests and responses instead of closing after a single exchange. Persistent connections are also called HTTP keep-alive and HTTP connection reuse.

An example of where a persistent connection is important can be found in an internet user's request to open a webpage. Accessing the page requires multiple content elements to be downloaded, including images, text and scripts. Without a persistent connection, each of those elements would require a new connection to the web server, leading to delays in displaying the full page. With the system providing a persistent connection, the download is accelerated.

Persistent connection function in HTTP

HTTP is an application-level protocol that typically runs on port 80. It uses Transmission Control Protocol (TCP) as an underlying transport protocol. TCP is a connection-oriented protocol: It starts a connection after confirmation from both ends that they are available and open to a data exchange.

A persistent connection function in HTTP 1.1, introduced in 1997, and later versions allowed the channel to remain open rather than closing after a requested exchange of data. The goal is to use a single TCP connection to send multiple HTTP requests and receive multiple HTTP responses, instead of opening a new connection for every request-response pair.

In early web technology based on HTTP 1.0, the server always closed connections after sending the response. Persistent connections added to this protocol used an extra header to request the client keep the connection alive. HTTP 1.1 assumes all connections to be persistent unless otherwise specified. In other words, persistent connections are the default behavior of any connection in HTTP 1.1. The HTTP/2 protocol expands the idea to enable multiple requests and returns of data to be exchanged simultaneously, or multiplexed, over a single connection.

Graphic showing how HTTP works with servers and webpages.
A persistent connection is a network communication channel that stays open for additional HTTP requests and responses instead of closing after an exchange.

Persistent connections vs. nonpersistent connections

The difference between persistent and nonpersistent connections becomes most obvious in terms of round-trip time (RTT). RTT is the duration in milliseconds from when a web browser first sends a request to when it receives a response from a web server. As a key performance metric for web applications, a lower RTT is always desirable. The RTT value is two times the value of the packet propagation time.

In persistent connections, the server leaves the connection open after sending a response. TCP keep-alive packets are sent to maintain the connection and prevent it from timing out. Subsequent HTTP messages between the server and clients are sent over this open connection. Further, the client sends a request to the server as soon as it encounters a referenced object -- for example, an image or text file. All of this reduces the RTT.

In a nonpersistent connection, the channel closes when one host signals that it wants to end communications or when a certain amount of time has elapsed with no exchange of data. There is some additional overhead for each TCP connection, so the RTT is higher. In addition, browsers often open parallel TCP connections to fetch referenced objects. This again increases the RTT and introduces latency into the network.

Benefits of persistent connections

An open and persistent connection is faster for frequent data exchanges. A connection that stays open rather than opening and closing sessions for each request also saves communications overhead. Persistent connections can be used with application programming interfaces to enable servers to push data to clients.

Other benefits of persistent connections include the following:

  • reduced network congestion due to fewer TCP connections and lower network traffic;
  • lower latency for subsequent requests because the initial TCP handshake is avoided;
  • less processor and memory usage due to the lower number of connections and fewer Secure Socket Layer/Transport Layer Security handshakes; and
  • support for HTTP pipelining of both requests and responses.

In addition, transmission errors can be reported without closing the persistent connection. And with long-lasting connections, the TCP gets sufficient time to determine the network's congestion state and then react appropriately.

Drawbacks of persistent connections

One drawback of a persistent connection is that if one client does not close the connection after receiving all its required data, other clients will be unable to access the resources needed to keep the connection open on the server. This can affect resource and server availability for these clients. The period of unavailability depends on the server's architecture and configuration.

Another problem is that when a client sends a request to the server at the same time that the server closes the TCP connection, it can result in what is known as a race condition. To avoid this issue, the server should send a "408 Request Timeout" status code to the client before closing the connection. On receiving this code, the client can open a new connection to the server and resend the request. However, not all clients will resend the request, leading to unexpected or undesirable results.

If proxy servers are in place, they must correctly signal all persistent or nonpersistent connections separately with all clients, origin servers and other proxy servers. This is because persistent connections apply to only one transport link.

Persistent connections for webpage requests

Persistent connections are frequently used for webpage requests. First, the web browser requests the page, parses it and identifies the resources -- such as images, cascading style sheets and scripts -- it will need to render that page. Since the browser requests these resources one by one, it is most efficient to maintain a persistent connection, which reduces the overhead and associated delays when new connections are created and destroyed.

From the perspective of the web server, a persistent connection allows the server to push content to the client's web browser. The webpage requests many different resources on the same server. When the server doesn't close the socket after it finishes pushing out one response, but instead reuses it for further requests, the browser can make other requests on the same socket, thus reducing the overall latency. The latency would be much higher if the original socket was closed and a new socket had to be opened for every follow-on request from the browser.

Persistent connections in web browsers

All modern web browsers such as Google Chrome, Mozilla Firefox and Microsoft Edge use persistent connections. However, these connections typically time out after a predefined period of inactivity. For most browsers, the timeout period can be modified from the Windows Registry.

For example, in Edge, this period is 1 minute. The browser will reuse the same TCP/IP socket that was used for the initial request until the socket is idle for 1 minute. After the minute has passed, it will reset the connection for additional requests, and a new TCP/IP socket will be used.

Explore alternatives to HTTP for microservices.

This was last updated in December 2022

Continue Reading About persistent connection

Networking
  • subnet (subnetwork)

    A subnet, or subnetwork, is a segmented piece of a larger network. More specifically, subnets are a logical partition of an IP ...

  • Transmission Control Protocol (TCP)

    Transmission Control Protocol (TCP) is a standard protocol on the internet that ensures the reliable transmission of data between...

  • secure access service edge (SASE)

    Secure access service edge (SASE), pronounced sassy, is a cloud architecture model that bundles together network and cloud-native...

Security
  • cyber attack

    A cyber attack is any malicious attempt to gain unauthorized access to a computer, computing system or computer network with the ...

  • digital signature

    A digital signature is a mathematical technique used to validate the authenticity and integrity of a digital document, message or...

  • What is security information and event management (SIEM)?

    Security information and event management (SIEM) is an approach to security management that combines security information ...

CIO
  • product development (new product development)

    Product development -- also called new product management -- is a series of steps that includes the conceptualization, design, ...

  • innovation culture

    Innovation culture is the work environment that leaders cultivate to nurture unorthodox thinking and its application.

  • technology addiction

    Technology addiction is an impulse control disorder that involves the obsessive use of mobile devices, the internet or video ...

HRSoftware
  • organizational network analysis (ONA)

    Organizational network analysis (ONA) is a quantitative method for modeling and analyzing how communications, information, ...

  • HireVue

    HireVue is an enterprise video interviewing technology provider of a platform that lets recruiters and hiring managers screen ...

  • Human Resource Certification Institute (HRCI)

    Human Resource Certification Institute (HRCI) is a U.S.-based credentialing organization offering certifications to HR ...

Customer Experience
  • contact center agent (call center agent)

    A contact center agent is a person who handles incoming or outgoing customer communications for an organization.

  • contact center management

    Contact center management is the process of overseeing contact center operations with the goal of providing an outstanding ...

  • digital marketing

    Digital marketing is the promotion and marketing of goods and services to consumers through digital channels and electronic ...

Close