Stateful vs Stateless backend architecture
Sun Mar 10
In the world of software design, two key architectural concepts define how applications handle information: stateful and stateless.
Stateful backend
-
The server is responsible for storing the state.
-
The functionality is dependent on the stored information
-
Example:
In a stateful architecture, the server maintains client session data and context across multiple requests. Each interaction between the client and the server builds upon previous interactions, allowing the system to retain knowledge of the client’s history and current state.
Stateful systems often utilize sessions, cookies, localstorage, or databases to store and manage this state information.
Sateless backend
-
The client is responsible for storing the state.
-
The functionality isn’t dependent on any stored data, rather each interaction is self-contained.
-
Example:
In a stateless architecture, the server processes each request based solely on the information provided within that request, without relying on any stored context or session information.
horizontal scaling: refers to the ability to increase the capacity of a system by adding more servers, rather than increasing the capacity of a single server.
This simplicity facilitates horizontal scaling and load balancing across multiple servers, as any server can handle any request without needing to synchronize state information with other servers. Which is also commonly deployed in microservices architecture