Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Construct a simple HTTP request on TCP protocol
Next article icon

HTTP Non-Persistent & Persistent Connection | Set 1

Last Updated : 30 Mar, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

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. 

HTTP Connections

  1. Non-Persistent
  2. Persistent

Basic Pre-Requisite

The terminology which we must know before going deep into Persistent & Non-Persistent Connections is 

  1. RTT(Round Trip Time)
  2. TCP 3-Way Handshake

1. RTT: Time for a small packet to travel from client to server and back.

RTT = 2 X propagation time

1. For a connection Persistent or Non-persistent it is sure that to initiate a TCP connection one RTT is used. 

2. One RTT is used for the HTTP request and the first few bytes to the HTTP response to return. So to know the total file transmission time.

Total = 2RTT + transmit time

2. TCP 3-Way Handshake: TCP Connection establishes in 3 ways, that’s why it is called a 3-way Handshake.

  • Requesting the server for the connection.
  • The server responds to whether the connection can be established or not.
  • Acknowledgment by the client on the response sent by the server.

Difference between Persistent and Non-Persistent Connections

Persistent HTTP Non-Persistent HTTP                                                                           
The server leaves the connection open after sending a response. Requires 2 RTTs per object.
Subsequent HTTP messages between the same client/server are sent over an open connection. OS overhead for each TCP connection
The client sends requests as soon as it encounters a referenced object. Browsers often open parallel TCP connections to fetch referenced objects.
As little as one RTT for all the referenced objects. Here, at most one object can be sent over one TCP Connection.

Non-Persistent Connection

Non-Persistent Connections are those connections in which for each object we have to create a new connection for sending that object from source to destination. Here, we can send a maximum of one object from one TCP connection.

There are two types:

1. Non-Persistent-Without parallel connection: Each objection takes two RTTs (assuming no window limit) one for TCP connection and the other for HTTP image/text file.

2. Non-Persistent-With parallel connection: Non-Persistent with a parallel connection requires extra overhead in transferring data.

Non-Persistent & Parallel Connection

Non-Persistent & Parallel Connection

Advantages of Non-Persistent Connection

  1. Wastage of Resources is very less because the connection opens only when there is some data to be sent.
  2. Non-Persistent Connection is more secure because after sending the data, the connection gets terminated and nothing can be shared thereafter.

Disadvantages of Non-Persistent Connection

  1. In Non-Persistent Connection, it requires a greater CPU overhead for the transmission of data

Persistent Connection

1. Non-Pipelined Persistent Connection: In a Non-pipeline connection, we first establish a connection that takes two RTTs then we send all the object’s images/text files which take 1 RTT each (TCP for each object is not required). 

2. Pipelined Persistent Connection: In Pipelined connection, 2RTT is for connection establishment and then 1RTT(assuming no window limit) for all the objects i.e. images/text. 

Persistent Without Pipelining and with Pipelining

Persistent Without Pipelining and with Pipelining

Advantages of Persistent Connections

  • Lower CPU and memory usage because there is less number of connections. 
  • Allows HTTP pipelining of requests and responses. 
  • Reduced network congestion (fewer TCP connections). 
  • Reduced latency in subsequent requests (no handshaking). 
  • Errors can be reported without the penalty of closing the TCP connection. 

Disadvantages of Persistent Connections

  • Resources may be kept occupied even when not needed and may not be available to others. 
  • Most modern browsers like Chrome, Firefox, and Internet Explorer use persistent connections.


Next Article
Construct a simple HTTP request on TCP protocol
https://media.geeksforgeeks.org/auth/avatar.png
GeeksforGeeks
Improve
Article Tags :
  • Computer Networks

Similar Reads

  • HTTP Non-Persistent & Persistent Connection | Set 2 (Practice Question)
    Prerequisite: HTTP Non-Persistent & Persistent Connection - Set 1 For question point of view you need to know that Non-persistent connection is known as HTTP 1.0 and Persistent connection is known as HTTP 1.1. Non-Persistent Connection: It requires connection setup again and again for each objec
    2 min read
  • Difference between 1-persistent, p-persistent and Non-persistent CSMA
    Carrier Sense Multiple Access (CSMA) is a network protocol used to control access to a shared communication channel. Before a device (or station) sends data, it first listens to the channel (also called carrier sensing) to check if it is busy or idle. If the channel is idle, the device starts transm
    5 min read
  • Difference between 1-Persistent and p-Persistent CSMA
    Prerequisite – Carrier Sense Multiple Access (CSMA) 1. 1-persistent CSMA : In 1-persistent CSMA, station continuously senses channel to check its state i.e. idle or busy so that it can transfer data. In case when channel is busy, station will wait for channel to become idle. When station finds an id
    3 min read
  • Construct a simple HTTP request on TCP protocol
    HTTP Request : HTTP messages are how data is exchanged between a server and a client. In this, there are two types of messages where one is HTTP client request and the second is the response from the server.Messages in textual form and it is encoded in ASCII form, and span over multiple lines. And m
    3 min read
  • Connection-less Service
    A Connectionless Service is technique that is used in data communications to send or transfer data or message at Layer 4 i.e., Transport Layer of Open System Interconnection model. This service does not require session connection among sender or source and receiver or destination. Sender starts tran
    3 min read
  • Web Caching and Conditional GET Statements
    Web caching is done by a Proxy Server - an intermediate entity between the original server and the client. When a client requests for some information (through an HTTP message), it goes through the proxy server, which - First checks if it has the copy locally stored. If it has, then it forwards the
    2 min read
  • HTTP Full Form - Hypertext Transfer Protocol
    HTTP is the primary method through which web browsers and servers communicate to share information on the internet. It was invented by Tim Berners-Lee. HyperText refers to text that is specially coded using a standard coding language called HyperText Markup Language (HTML). HTTP/2 is the updated ver
    8 min read
  • Internetworking Terms and Concepts
    The term Internetworking means interconnection i.e. interconnecting two or more computers. Inter means between and networking means the exchange of information or data among multiple connected devices. Internetworking means connecting two or more computer networks using devices like routers, gateway
    3 min read
  • Session Management in HTTP
    HTTP is a "stateless" protocol. Which means there is no "built-in" standard to keep track of interrelated requests. Each request is treated as independent. Currently, most of the web applications are using HTTP 1.1 which was released in 1996. These web applications are very advanced and usually hand
    4 min read
  • WebSockets Protocol and Long Polling
    As one facet of net development, real-time access Among consumers and servers has now become an important step in creating interactive web programs as well as mouth-watering. Request-reaction mechanisms, even flexible and powerful as they are, may not be suitable for circumstances that call for rapi
    10 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences