Open In App

RESTful Statelessness

Improve
Improve
Like Article
Like
Save
Share
Report

REST is an acronym for REpresentational State Transfer and an architectural style for distributed hypermedia systems.

The six guiding principles or Constraints of REST are:

  1. Uniform Interface
  2. Client-Server
  3. Stateless
  4. Cacheable
  5. Layered architecture
  6. Code on demand (optional).

We will discuss the Stateless constraint of REST in-depth in this article.

NOTE: As per the REST{Representational “State” Transfer } architecture, the server does not store any information about the client-side on the server-side.

Each request from the client to server must contain all the information needed to process that request and that information cannot be stored at the server side for any future reference. This restriction is called Statelessness.

The client is responsible for storing and handling the session-related information on its own side. If any information is required from the previous request, the client will share it in the current request.

Statelessness means that every HTTP request happens in complete isolation”.

Application state is the information stored at the server side to identify incoming requests and previous interactions, REST statelessness means being free from the application state.

Advantages of REST Statelessness:

  • Easily Scalable: As there is no need for any stored information, any server can handle any client request. Thus, many concurrent requests can be processed by deploying API to multiple servers.
  • Decreased Complexity: As state synchronization is not needed, it reduces the complexity.
  • Improved Performance: Server doesn’t need to keep track of client requests, which increases the performance.

Disadvantages of REST Statelessness:

  • Increased request size: The request size becomes very big many times as it contains all the information about the request and previous transactions.

EXAMPLE of Statelessness:

Suppose we have an API where we want to log in and order some goods, the API deployed on many servers can serve many requests, even from the same account without storing the authentication details or provided token state.

Every time client is making a request it will send the authentication details as well as the other required information and that request can be processed easily at the server side as it includes all the information needed to fulfill the request.


Last Updated : 03 Mar, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads