Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a stateless state in web app or websites

I am just into learning the basics of web application development. As i was reading the different approaches like ASP.Net Web Forms, ASP.Net MVC ,etc. Most of the tutorials mentioned the term 'stateless' when explaining about MVC and all. I was unable to get the term correctly. Could you help explaining a bit about it.

Thanks

like image 258
Thomas Mathew Avatar asked Jan 25 '26 07:01

Thomas Mathew


2 Answers

this means web applications in general. Stateless means that there is no persistant connection between server and client. The client say "Hey google.com, gimme that site" and google response.. After that the connection is closed.

Do you need more informations ?

like image 72
dknaack Avatar answered Jan 27 '26 01:01

dknaack


State here refers to the interaction state that a server maintains for each of its connected client. (Note that it has nothing to do with MVC.)

Or in other words:

You walk into a burger joint and there are a few people behind the counter helping people with their orders.

The burger joint's process is 'stateless' if, in every single interaction with the people behind the counter any one of the workers behind the counter would be able to serve the customer. For example, you say "give me a burger" and someone gives you a burger. You say "Katchup?" and someone else gives you what you asked.

If it was a 'stateful' burger joint you form queues, and each client gets a specific person behind the counter to see them through their whole order.

What's the difference?

In the first case, regardless of what happens to any of the workers behind the counter your order progresses step by step. Each step may have been handled by a different worker (or also possible that it randomly happens that the same worker does it all, but that's just chance). You simply continue with your orders to the counter.

In the second case, if something happens mid-order to your server, the state of the conversation must be passed to another server so it may continue to server you. Otherwise you need to start from scratch. Saving the state costs a bit of effort -- you need to write it down somewhere and in case of the out-of-action-server the other server that takes over your order needs to get that state and resume the interaction where it was left off.

How about scaling the burger joint for the lunch rush?

In both cases, the manager can simply add new workers behind the counter.

Given the stateless state of affairs of the first case, the new workers can join the operations and start contributing to clients already in middle of an order. Some says "Katchup?" and perhaps a new server pipes back "here you go".

In the second case, each additional servers can only help with new orders (but not orders already in progress).

like image 27
alphazero Avatar answered Jan 26 '26 23:01

alphazero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!