The Hypertext Transfer Protocol (HTTP) is an application-level protocol that uses TCP as an underlying transport and typically runs on port 80. HTTP is a stateless protocol i.e. server maintains no information about past client requests.
Before starting with persistent and non-persistent HTTP connection lets know what is a RTT.
RTT-> Time for a small packet to travel from client to server and back.
RTT= 2*propagation time
1. For an connection Persistent or Non-persistent it is sure that to initiate TCP connection one RTT is used.
2. One RTT is used for HTTP request and first few bytes to HTTP response to return.
So in order to know total file transmission time->
total = 2RTT+transmit time
Difference between Persistent & Non-Persistent connection.
- Without parallel connection
- With parallel connection
Without parallel connection Non-Persistent
Each objection takes two RTT (assuming no window limit) one for TCP connection and other for HTTP image/text file.
With parallel connection Non-Persistent
In Non-pipeline connection we first establish connection which takes two RTT then we send all the objects images/text files which takes 1 RTT each (TCP for each object is not required).
In Pipelined connection 2RTT for connection establishment and then 1RTT(assuming no window limit) for all the objects i.e. images/text.
Advantages of persistent connections :
1) Lower CPU and memory usage because there are less number of connections.
2) Allows HTTP pipelining of requests and responses.
3) Reduced network congestion (fewer TCP connections).
4) Reduced latency in subsequent requests (no handshaking).
5) Errors can be reported without the penalty of closing the TCP connection.
Disadvantages of persistent connections :
Resources may be be kept occupied even when not needed and may not be available to others.
Most of the modern browsers like Chrome, Firefox and Internet Explorer use persistent connections.
This article is contributed by SHAURYA UPPAL. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Difference between HTML and HTTP
- Difference between http:// and https://
- HTTP Non-Persistent & Persistent Connection | Set 2 (Practice Question)
- TCP Connection Termination
- TCP Connection Establishment
- What are the differences between HTTP, FTP, and SMTP?
- Session Management in HTTP
- Difference between Connection-oriented and Connection-less Services
- Difference between HTTP and IPFS
- Stop and Wait protocol, its problems and solutions
- Difference between segments, packets and frames
- Finding DBA from given IP address
- Difference between Supercomputing and Quantum Computing
- 192.168.0.1 Admin Login