...

/

Stateful vs. Stateless Applications and Session Management

Stateful vs. Stateless Applications and Session Management

Why does it matter?

A client wants the server to complete a certain task e.g.

  • Upload a Photo to Instagram
  • Place an Order at Amazon

For each of these tasks, the client and server will most likely exchange multiple requests and responses.

The discussion of Stateful vs. Stateless services is only relevant if the client and server are exchanging more than one message to complete a certain task (which is the case most of the time)

What is State?

When a client starts a session with the server, it might require multiple requests and responses to complete that transaction, e.g., when you are ordering on Amazon, you might add a few menu items to your cart and then click “buy.” Every time you are adding an item into the cart, the server is noting it down somewhere. That data about the items in your order is called state.

What is a Stateless application

An application that doesn’t save any data between requests associated with a specific session is called a stateless application, e.g., a website that shows you the weather of a particular zip code. Every time, you change the zip code, it goes to the server and fetches the weather for the given zip code without having to rely on what requests were sent before.

What is a stateful application

The application that saves any “data” or “state” between ...

Access this course and 1400+ top-rated courses and projects.