<p>I just started learning swarm recently. And I have some questions about the swarm usage scenario.</p>

<p>If I have a simple webserver which response to some restful HTTP requests，swarm seems to be a good choice because if I need to expand my webserver horizontally, I just need to use <code>docker service scale</code> and the swarm will do load balancing for me.</p>

<p>But what about services that have their own clustering mechanism(Redis, elastic search?)?  I cannot simply expand the capacity through the <code>docker</code> service scale`. </p>

<p>For instance, I have a Redis service, if I <code>docker service scale redis=2</code>, two separate Redis services are generated. This is obviously not what I need.</p>

<p>Are these services fit for swarm mode？If so, how to config these services in swarm mode? And how to expand it? </p>

<p>Stateful services (e.g. Redis, RabbitMQ, etc...) fit swarm mode. </p>

<p>It's your responsibility though to configure the cluster manually, by some predeploy/postdeploy script or in images entrypoint.</p>

<p>Such reconfiguration should run also after each replica restart regardless the reason: single replica failures and subsequent restarts, restart of all service replicas, scaling of new replicas. </p>

<p>Content of such script/steps may vary between clustering solutions and one should refer to the relevant documentation of each solution. It maybe as simple as putting replicas virtual ips to configuration file or complex ordered steps.</p>

<p>General use cases that fit all solutions are: configure cluster inside service replicas for the first time, connect single  replica back to cluster after failure, restart all replicas after failure/valid restart.</p>

<p>Some github projects try to automate the process. For example <a href="https://hub.docker.com/r/toughiq/mariadb-cluster/" rel="nofollow noreferrer">mariadb-cluster</a> </p>
