Stateless and Connectionless HTTP Protocol

Stateless and Connectionless HTTP Protocol

About HTTP Protocol

What is HTTP (HyperText Transfer Protocol) Protocol?

A protocol sets standards for communication between systems, client to server or among servers. HTTP is specially meant to communicate between Client and Server using Web (or Internet). It was developed by W3C (World Wide Web Consortium) around in the year 1995. HTTP is an application layer level protocol in IP Suite. The client uses HTTP protocol to locate the Server using URLs. HTTP is today’s defacto standard protocol over Web to transfer hyper media (hypertext) data.

What is Connectionless Protocol?

We know HTTP is used by client to request the server for some information over the Web. The client establishes a connection with the server before sending a request. Over this connection only, the server returns the response to client. When the response is delivered, the connection between client and server is destroyed. By chance, if the same client would like to contact the same server again, the client should establish altogether a new connection. To put in a simple way, if the client would like to request the same server 100 times, the client should establish a new connection 100 times as the server closes the connection for each request when the response is delivered.

You may think it is a big overhead to the client. Ofcourse, you are right. Then, why HTTP was designed as connectionless? HTTP Protocol was designed as connectionless for the reason, the server resources should be shared equally by all the clients throughout world. If one client holds the server with 100 requests, by all the requests are answered, the server cannot allocate time for other clients.

Now which is better? It is wise to distribute the server time equally for all the clients waiting. For this reason, the server closes the connection immediately (no fixed or prior arranged channel between ends points client and server) when the response is delivered to client.

It can be compared to a Student and Lecturer. If the student in a class engages the Lecturer for 100 doubts and posts one after another, then what about the other students in the class. The student with 100 doubts also should come in round-robin fashion. For this reason, the HTTP was designed to be connectionless. HTTP is also known as CL-mode communication.

What is Stateless Protocol?

Now think a scenario. A client requested some information and the server honoured. In the next minute, the client requested the server to send back the same information as it lost the data. Simply server questions the client – Who are you? That is, server does not maintain the track (or record) of client Vs the response delivered, or to say, does not maintain the state of the client. That is, when the response is delivered, the server simply forgets the client. If the client wants the same data, it must again establish a new connection, send request and receive response and the same earlier process is to be repeated. For this reason, HTTP protocol is treated as stateless protocol.

That is, each request is treated as a separate and independent transaction that is not related at all with any previous requests. It is so developed by W3C, just to avoid the extra overhead of computation and hard disk space on the server.

HTTP Protocol, which is once the most advantageous being connectionless and stateless, now became a minus point over the time. With this nature of HTTP Protocol, it is not possible to develop e-commerce applications where on a single connection, lot of data should be transferred between Client and Server multiple times. To overcome this in Servlets and JSP, there comes session, session management, session tracking etc. in Servlets.

4 thoughts on “Stateless and Connectionless HTTP Protocol

  1. Shailendra

    I have read that http is connections and stateless protocol, but never understood the practical meaning. Sir, you made my day :) thank you for writing the article on it.

Leave a Reply

Your email address will not be published. Required fields are marked *