Stateless services

It is important to understand the power of stateless services. Think of a scenario where a service is maintaining some kind of state; say a user can fill in form 2 only if they have filled in form 1, and we are trying to keep this information within the application, say in a session. The problem is that we will need to make sure that the same service instance receives a request from the same user. There are solutions, such as sticky sessions or replication of session, but they add to the overhead and complexity of the system.

Using stateful services makes it difficult to isolate the failure. If the service is in an error state or responding slowly, it is not easy to redirect the traffic to some other node or simply restart the node, as we will lose the information state information maintained locally.

We will talk more about stateless services with an example in Chapter 6Scaling Microservices, when we discuss scaling Microservices.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.37.191