How to scale Docker Swarm services

Jack Wallen demonstrates how to attach and remove nodes from clusters in Docker Swarm to scale your services up and down as needed.

[embedded content]

If Docker Swarm is your container cluster technology of choice, you’re going to want to know how to scale up and down the services you deploy.

When you need more power to meet a higher demand, scale those services up. When demand lowers during off-peak hours, scale them down. This is a great way to help keep costs down, especially when your containers are hosted on a third-party service such as Google, AWS or Azure.

You might be surprised to find out that scaling services up and down on Docker Swarm is actually quite easy. In fact, it’s done with a single command, and you only need to change the number of nodes the service will scale to.

As for the scalability, it is limited to the number of nodes you have attached to the cluster. For example, if you have 100 nodes attached 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 a previously deployed service called nginx_test.

Check how many nodes the service has been deployed to with the command docker service list. As you can see, nginx_test has only been deployed to 1 node.

Let’s up that to 3 nodes with the command docker service scale nginx_test=3. You can then verify the service scaled 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 down, the command is similar to when you scaled it up, 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 on Docker Swarm up or down. Use this feature wisely to ensure your services can meet increased demand when needed.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Leave a Reply

Your email address will not be published. Required fields are marked *