We saw how services could self-heal. It was relatively easy to set up a system that would make sure that the desired number of replicas of each service is (almost) always running. Docker Swarm does all the work. As long as there are enough available hardware resources, our services will (almost) always run the specified number of replicas. All we have to do is specify replicas: [NUMBER_OF_REPLICAS] in the YAML file that defines our stack.
The problem with self-healing is that it does not take into account changes that affect our systems. We'll run the same number of replicas even if there is a huge spike in their memory utilization. The same applies if, for example, network traffic increases. Docker Swarm will not make sure that our system adapts to changed conditions. It will follow the blueprint blindly. While that is a vast improvement compared to how we operated the system in the past, it is, by no means, enough. We need the system both to self-heal and self-adapt.
In this chapter, we'll expand on the knowledge we obtained by now and start exploring ways we can make the system self-adapt. For now, we'll limit ourselves to services and ignore that hardware needs to heal and adapt as well. That will come later.