Problems when scaling stateful instances
Scaling services inside a Swarm cluster is easy, isn't it? Just execute docker service scale <SERVICE_NAME>=<NUMBER_OF_INSTANCES>
and, all of a sudden, the service is running multiple copies.
The previous statement is only partly true. The more precise wording would be that "scaling stateless services inside a Swarm cluster is easy".
The reason that scaling stateless services is easy lies in the fact that there is no state to think about. An instance is the same no matter how long it runs. There is no difference between a new instance and one that run for a week. Since the state does not change over time, we can create new copies at any given moment, and they will all be exactly the same.
However, the world is not stateless. State is an unavoidable part of our industry. As soon as the first piece of information is created, it needs to be stored somewhere. The place we store data must be stateful. It has a state that changes over time. If...