What are the difference between stateful and stateless microservices? Why microservices should be stateless?

What are the difference between stateful and stateless microservices? Why microservices should be stateless?

4 Likes

@radhika Could you please answer ?

2 Likes

@aakriti.kamboj
Stateful and Stateless applications store state from client requests on the server itself and use that state to process further requests.
It uses DB for storing data as a backend, but session information stored on the server itself. When a user sends a login request, it enables login to be true and user authenticated now, and on the second request, the user sees the dashboard.
Stateful applications don’t need to make a call to DB second time as session info stored on the server itself

4 Likes

Statelessness has several advantages for microservices, such as
improved scalability due to load balancing
reduced complexity
enhanced reliability

4 Likes