Search code examples
cloudmicroservices

Why Microservices better to be stateless in cloud applications?


As far as I understood they better to be stateless because the state of the overall application will be encapsulated inside a subset of micro services, avoiding it spreads over to the other components of the system (allowing them to be stateless)

Can someone elaborate/add on this ?

Thank you


Solution

  • I think there are two main reasons services should be stateless

    1. A statefull service can not be scaled as easily. If you want to deploy more units on peek times a stateless service is way easier to handle
    2. Statless services allow you to not worry about other services while developing. Just the possibility that one service has to behave differently because another services is in a specific state is very confusing and will eventually get a "distributed monolith"