You are on page 1of 3

State = condition or quality of being available at a given point of time

Whether stateful / stateless, depend on:

- The length of interaction a client has with it


- How much information is stored?

Stateful

- connection is maintained from beginning to the end of call to ensure continuous communication.

- connection is validated first, then session will be established indefinitely, until end of talk

- If client deliver a request to server in stateful protocol, it expect a response of some sort

- if no response, it will send the request again

Feature: it maintains the state of all its sessions, be in an authentication session, or client request for
information

- Use in repeatedly such as: online banking, email

- context of prior transaction in which the state is stored. Previous transaction will have impact on
current transaction

- Use same server every time perform a user request

Advantages

1. Improve performance when data retrieval is required only once

2. Keep track of the connection information, as a result, deliver superior performance because they
continue keeping track of information

3. More intuitive because they maintain data on server between two requests

Disadvantages

1. Highly dependent on the server-side state

2. Require memory allocation in order to store data

3. Usually require backing storage

4. As the state is maintained, stateful is not very secure

5. If there is inefficient maintenance of session storage, there can be decrease in the performance

6. Require continuous management of the service’s full lifecycle

Stateless

- Receiver’s availability is not confirmed, sender just send the SMS

- No confirmation from the receiving device to the sending device that message has been received

- Also no knowing that communication may or may not be received

- Can be no cross-verification of status


* Receiver not required to keep session state from previous request. Sender send session state to
receiver, where each request may be interpreted without reference to prior requests session state,
which receiver retains.

- Once transaction is completed, connection between the browser and the server is also terminated

Advantages

1. Each individual communication is unconnected and distinct from the ones that come before or
after it

2. Since monitoring system does not have to look beyond a single request to determine its whole
nature, visibility of the protocol is improved

3. Each packet of data travel on its own, no need to refer to another packet

4. Server does not have to store session state between requests; hence, scalability is enhanced as
deploying the services to any number of servers is possible, implementation is simplified even more

5. Easy to recover from partial failures like crashes since no state is maintained, which improved
reliability

Disadvantages

1. Less capable as they do not store any information about a particular user session

2. May be essential to include additional information in each request, as a result, server will need to
interpret this new information every time it received

3. May degrade network performance by increasing the amount of repetitive data delivery tasks in a
series of requests, which cannot be saved and reused.

Stateful Stateless
Require the server to save the state of a No server needed
process
Require a server to store and save status No server needed
information and details of sessions
Server and clients are tightly coupled, and are Server and clients are more independent and
extremely interdependent on each other hence, loosely coupled
Logically heavy to implement Easier to implement
React only by the current state of a transaction Act independently by taking the previous or
or request next request into consideration
Expect a response, if no answer is received, the Client send request to server, which the server
request is resent responds to based on the state of the request
Scaling architecture is difficult and more Easier to scale architecture
complex
Difficult to code as one of the salient features Much easier to code
here is data storage
Example: Telnet & FTP (File Transfer Protocol) Example: HTTP, UDP (User Datagram Protocol),
DNS (Domain Name System), REST APIs
Is stateless better than stateful?

Stateless better when: you only require information in a transient, rapid and temporary manner
Stateful better when: your app requires more memory of what happened from one session to the
next

Abstraction benefit, refer: https://bankloch.blogspot.com/2020/02/abstraction-in-financial-it-how-


far-can.html

You might also like