State:
Stateful website:
- A user is using a website, and the user is connected to a server1. If server1 fails, then the user is connected to server2. However, the user data is stored in server1, the user has to start over from the beginning since server2 does not have the state of the user.
- load balancer takes care of the routing to server1 and server2, but since server1 has the user session, when LB connects the user to the server2, the user has to authenticate again
- Stateful application is not horizontally scalable
- session is maintained in the server
- example applications: online banking, email
Stateless website:
- web server accesses state from database
- after a user authenticate, the server sends token back to the user, then the user attach the token to the request, and the user successfully gains access to multiple servers
- the server has to verify the token
- easily scalable
- RestAPI is stateless
- when you make a request, all the necessary information has to be stored in the http request
- State data is stored in the shared data store(not on each servers), and servers access to the data store to fetch state data