All posts
Architecture · 12 min read · Jan 14, 2026

Stateless vs Stateful Systems

Stateless versus stateful architecture

Stateless versus stateful is one of those distinctions that sounds academic until it decides whether your system can scale horizontally, survive a node crash, or deploy without dropping user sessions. The confusion usually starts with the word stateless, which people read as 'has no state.' No useful system is truly stateless. The real question is where the state lives and whether any single server is responsible for remembering it.

Defining the terms precisely

A stateless component keeps no client-specific state between requests. Every request carries everything needed to process it, and any instance can handle any request. A stateful component remembers something about the client across requests - a session, an in-progress transaction, a connection - so requests from the same client must reach the instance that holds that state, or the state must be shared.

PropertyStatelessStateful
Request routingAny instance can serve any requestRequests may be pinned to an instance
ScalingAdd instances freelyScaling requires moving or sharing state
Failure impactLose an instance, lose nothingLose an instance, lose its state
DeploymentRolling restarts are trivialMust drain or migrate state first

State does not disappear - it moves

Making a service stateless does not eliminate state; it relocates it. A stateless web tier pushes session state into a shared store like a cache or database, or encodes it in a token the client carries. The state still exists - it just no longer lives in the memory of one particular server. This relocation is the whole trick, and it is why 'go stateless' is really 'externalize your state.'

  • Client-held state: a signed token carries identity and claims, so no server needs to remember the session.
  • Shared store: sessions live in a distributed cache or database that every instance can read.
  • Sticky sessions: a load balancer pins a client to one instance - simple, but it undermines the benefits of statelessness.

Why stateless scales so well

Stateless services scale horizontally because instances are interchangeable. A load balancer can send a request to any of them, add capacity by starting more, and remove capacity by killing some, with no coordination. This interchangeability is also what makes stateless services easy to put behind an API gateway and easy to deploy with zero downtime.

When state is unavoidable

Plenty of things are inherently stateful: databases, message brokers, caches, and long-lived connections like WebSockets. The goal is not to pretend these do not exist but to concentrate state in components designed to manage it - systems with replication, persistence, and failover - and keep the rest of the architecture stateless around them.

This is why real-time features like WebSockets need extra thought: a live connection is state bound to a specific server, so scaling them means routing messages between servers rather than assuming any instance can serve any client.

The trade-offs are real

ConcernStateless approachCost
Session lookupRead from shared store per requestExtra latency and a dependency
Token-based stateClient carries signed claimsHard to revoke before expiry; size limits
Stateful with stickinessKeep state in memoryUneven load, lost state on crash

Practical guidance

  1. Default the request-handling tier to stateless so it can scale and redeploy freely.
  2. Externalize session and transient state into a store built for it, or into client-held tokens.
  3. Isolate unavoidable state into dedicated stateful systems with proper replication and failover.
  4. Treat sticky sessions as a last resort, not a design foundation.

Conclusion

Stateless versus stateful is not a question of whether state exists but of where it lives and who owns it. Push state out of your request handlers so they become interchangeable and easy to scale, and concentrate the state you cannot avoid into systems purpose-built to keep it safe. Get that division right and scaling, deployment, and failure recovery all become dramatically simpler.

Contact

Let’s connect

Have a Liferay or Backend project you’d like to talk through? Fill in the form and I’ll get back to you.

Book Calendar