Persistent HTTPS Connections: Reduce API call time by 50%


HTTP persistent connection, also called HTTP keep-alive, or HTTP connection reuse, is the idea of using a single TCP connection to send and receive multiple HTTP requests/responses, as opposed to opening a new connection for every single request/response pair. The newer HTTP/2 protocol uses the same idea and takes it further to allow multiple concurrent requests/responses to be multiplexed over a single connection.

Screen Shot 2018-10-10 at 11.36.49 PM

In HTTP 1.1, all connections are considered persistent unless declared otherwise. The HTTP persistent connections do not use separate keep-alive messages, they just allow multiple requests to use a single connection. However, the default connection timeout of Apache httpd 1.3 and 2.0 is as little as 15 seconds and just 5 seconds for Apache httpd 2.2 and above. The advantage of a short timeout is the ability to deliver multiple components of a web page quickly while not consuming resources to run multiple server processes or threads for too long.

Connection: keep-alive

Keep-alive with chunked transfer encoding

Keep-alive makes it difficult for the client to determine where one response ends and the next response begins, particularly during pipelined HTTP operation.This is a serious problem when Content-Length cannot be used due to streaming. To solve this problem, HTTP 1.1 introduced a chunked transfer coding that defines a last-chunk bit.The last-chunk bit is set at the end of each response so that the client knows where the next response begins.

Advantages

  • Reduced latency in subsequent requests (no handshaking).
  • Reduced CPU usage and round-trips because of fewer new connections and TLS handshakes.
  • Enables HTTP pipelining of requests and responses.
  • Reduced network congestion (fewer TCP connections).
  • Errors can be reported without the penalty of closing the TCP connection.

Disadvantages

If the client does not close the connection when all of the data it needs has been received, the resources needed to keep the connection open on the server will be unavailable for other clients. How much this affects the server’s availability and how long the resources are unavailable depend on the server’s architecture and configuration.

Screen Shot 2018-10-10 at 11.44.38 PM.png

How we can use this technology in iOS ???

To be continue……

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: