Skip to content
BENIBIX Learn

Stateful Service

Development🏗️ ArchitectureArchitecture Basics

Also known as Stateful Application, Stateful Server, Stateful Process

A service that keeps data between calls. So the right copy must answer.

Think of it like

It is like your own doctor who keeps your file. You have to go back to the same one.

Example

Emma's chat server keeps each open chat in memory. When it restarts, every user in those chats is cut off and has to join again.

Why it matters

Some jobs need state, like databases and live games. Knowing which parts hold state tells you what needs backups and careful moves.

Definition

A stateful service keeps data from past requests inside itself and needs it for the next one. A game server holds each match in memory. A database holds its rows on its own disk. Requests for that data must reach the copy that holds it. That makes the service harder to grow, move or restart than a stateless one.
Stateful, on the right: only copy B has the game. So each call must go to B.

Common mistake

Making a web app stateful by mistake, by keeping logins in memory. Keep state in the few parts built for it, like the database.

Key takeaways

  1. 1
    Remembers. Data stays between requests.
  2. 2
    The right copy only. Requests must find it.
  3. 3
    Handle with care. Back it up, move it slowly.

Compare