top of page
Search
Writer's pictureAnvita Bajpai

Stateless vs Stateful Systems - A Closer Look




What is State?

State represents the data that is stored and used to keep track of the current status of the application. Understanding and managing state is crucial for building interactive and dynamic web applications.


Stateless


Stateless applications and processes do not maintain any state within the services across calls. They take in a request, process it, and send a response back without persisting any state information. A stateful service persists state in some form in order for it to function.

Rather than store this state internally, a service should store state information externally, in some type of data store. Examples of a data store to persist state include a relational database management system (RDBMS), a NoSQL database, or some caching component.


Stateful


Stateful applications and processes, however, are those that can be returned to again and again, like online banking or email. They’re performed with the context of previous transactions and the current transaction may be affected by what happened during previous transactions. For these reasons, stateful apps use the same servers each time they process a request from a user. You can think of stateful transactions as an ongoing periodic conversation with the same person.


Stateful vs Stateless: A comparison



Real-life Analogy for a Stateful System

In the scenario described below:
State at any instance is saved locally per customer-agent

Illustration of a user talking to a customer-care agent and explaining his problem in detail - in a stateful system.


Illustration of the same user now talking to a different customer-care agent after the call got disconnected abruptly due to some connection error. He now has to repeat the whole problem description with this new agent once again as the previous state of the conversation was saved only with the previous custom-care agent. The state is therefore lost after the call disconnection with the previous agent as the state of the conversation with the user was locally saved with a specific customer-agent.


Real-life Analogy for a Stateless System


In the scenario described below:
Stateless system where the state at any instance is not saved locally per customer-agent rather persisted in a centralized system which can then be retrieved by any agent

Illustration of a user talking to a customer-care agent and explaining his problem in detail - in a stateless system.


Illustration of the same user now talking to a different customer-care agent after the call got disconnected abruptly due to some connection error. This being a stateless system did not have the user's conversation state saved locally with the previous agent only, it was rather persisted in a centralized location and therefore the new agent was able to retrieve is easily and process the request

easily and quickly without requiring to get all the details from the user again.


Conclusion


Stateful and stateless architectures offer distinct advantages and disadvantages depending on the requirements and constraints of the system at hand. Stateful architectures provide simplicity, enhanced user experience, and efficient resource utilization but can face scalability, fault tolerance, and load-balancing challenges. On the other hand, stateless architectures offer scalability, fault tolerance, and ease of deployment but may suffer from increased network traffic, loss of session context, and additional security considerations. Architects and developers must carefully evaluate these factors and consider the specific needs of their applications to determine which architecture is most suitable for their project.


References




116 views0 comments

Recent Posts

See All

Comments


Copyright © 2020 TechTalksByAnvita

bottom of page