Jack Wallen demonstrates how to add and remove nodes from a cluster in Docker Swarm to scale your services up and down as needed.
If Docker Swarm is your container cluster technology of choice, you’ll want to know how to scale up and scale down the services you deploy.
Scale up those services when you need more power to meet higher demand. When demand drops during off-peak hours, reduce them. This is a great way to help keep costs down, especially when your containers are hosted on a third-party service like Google, AWS, or Azure.
You might be surprised to learn that it’s actually quite easy to scale services up and down on Docker Swarm. In fact, this is done with a single command, and you only need to change the number of nodes the service will scale on.
For scalability, it is limited by the number of nodes you have connected to the cluster. For example, if you have 100 nodes connected to the swarm, your maximum scale would be 100. If you only have 3 nodes, your max is 3. Let me show you how it’s done.
I’ll demonstrate with an already deployed service called nginx_test.
Check how many nodes the service is deployed with the command docker service list . As you can see, nginx_test is only deployed on 1 node.
Let’s scale this up to 3 nodes with the docker service scale nginx_test=3 command. You can then verify the scaled service with the command docker service list . This time it should show nginx_test on 3/3 nodes.
When it comes time to scale that service back, the command is the same as when you scaled it down, only we’ll use 1 instead of 3, as in docker service scale nginx_test=1 .
And that’s all there is to scaling a service up or down on Docker Swarm. Use this facility wisely to ensure that your services can meet increased demand when needed.
Subscribe to TechRepublic how to do tech work on YouTube for all the latest tech advice from Jack Wallen for business pros.











