What is stateful interaction?
Stateful interaction is a way for a client and a server to communicate where the server stores the client's state (context) between requests.
In simpler terms: the server "remembers" the client and the previous steps of the conversation.
What "stateful" means in plain words
If an interaction is stateful:
- the server knows who you are
- the server remembers what happened before
- the next request depends on the previous ones
A single request is not a standalone event, it is part of an ongoing dialogue.
What this looks like in practice
- The client connects to the server
- The server creates a session and remembers the client's state
- The client sends requests
- The server:
- uses the stored state
- understands the context
- continues from the same point
The client does not need to send all the information every time.
A real-life example
Stateful is like talking to a personal manager at a bank:
- you arrive
- the manager opens your file
- they remember who you are and why you came
- each next question is part of the same conversation
If you leave and come back later, the conversation can continue, instead of starting over.
Where stateful interaction is used
Common examples:
- working with sessions
- applications with a persistent connection
- chats and online games
- protocols where the connection's state matters
The server stores:
- session data
- the steps of the dialogue
- intermediate results
Advantages and disadvantages
Advantages:
- more convenient for complex scenarios
- less data in each request
- simpler client logic
Disadvantages:
- harder to scale
- the server spends memory on state
- if there is a failure, the state can be lost
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.