# Stateful Service

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

**Field:** Software Development  
**Category:** Architecture  
**Also known as:** Stateful Application, Stateful Server, Stateful Process

## Think of it like

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

## 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.

## 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.

## 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.

## Three principles

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

## Related terms

- [Stateless Service](https://learn.benibix.com/term/development/stateless-service)
- [Database Replication](https://learn.benibix.com/term/development/database-replication)
- [Database Sharding](https://learn.benibix.com/term/development/sharding)
- [Session (Web)](https://learn.benibix.com/term/development/session)
- [Distributed System](https://learn.benibix.com/term/development/distributed-system)
- [Single Point of Failure](https://learn.benibix.com/term/development/single-point-of-failure)

## Told apart from

- [Stateless Service vs Stateful Service](https://learn.benibix.com/compare/stateless-service-vs-stateful-service): People think a stateless service keeps no data, and that is not quite right. It keeps none inside itself between requests. The cart or the login lives in a shared store, so any copy can answer. A stateful service keeps that data in its own memory or disk. Each request must reach the one copy that has it.

![Two panels. On the left, stateless: a user's requests can go to any of three app copies, and all three read the user's cart from one shared cache. On the right, stateful: a user's requests must all go to copy B, because only copy B holds that user's game in its memory. Copies A and C cannot help.](https://learn.benibix.com/diagrams/dev6-stateless-stateful.svg)

---

Source: https://learn.benibix.com/term/development/stateful-service
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
