You’ve heard of Docker. Duh. And if you’re like me, you LOVE it. (I mean, what’s not to love?) At some point when you use Docker you run across this term: Docker Swarm. Everybody talks about it, but the heck is it?
In a nutshell, Swarm (more accurately, swarm mode) is Docker’s native support for orchestrating clusters of Docker engines. Sounds great, but what does that mean? Not to worry, I’ll break it down for you in this post.
Containers are great, but when you get lots of them running, at some point, you need them all working together to solve business problems.
The problem is, when you have lots of containers running, they need to be managed: you want enough of them running to handle the load, but not so many they are bogging down the machines in the cluster. And well, from time to time, containers are going to crash, and need to be restarted.
In other words, all those wonderful, nifty containers need to be orchestrated (or it’s just chaos, man).
Finding the sweet spot
The longer I’ve been in software development, the more important I believe it is to find the right tool for the job. It’s not always easy to tell when you have the right tool in use, or if there is even a “right” tool to use. So this can be tricky.
Is this really a problem? I believe it is. Why, you ask?
Well, there is a always a trade off between the overhead required to learn the tool – mostly to figure out how to configure it, am I right? – and the benefits provided by using it.
So we look for that (ideally) perfect balance between usability and ease-of-configuration. You know, the sweet spot.
Native vs 3P
Complicated setup sucks. Period. If solving a problem requires a bunch of tools that all have to be installed and configured to work together (and periodically patched and upgraded) that can be a real administrative headache. Like I said, it sucks.
But what do you do when the capabilities you need aren’t provided natively by the tools? You have to seek out a separate solution, and often that means a third party product (or if you’re lucky, a separate product from the same vendor).
When capabilities are built in (i.e., native) to the tool you’re already using the setup tends to be easier, more familiar, and just generally less painful (not to mention easier to keep up-to-date).
What Docker Swarm is NOT
A cloud management tool
Swarm can run in a cloud, but does not provide the IaaS that a cloud provider does.
Docker Swarm doesn’t manage your cloud, but rather it orchestrates Docker containers within the cloud.
A standalone product (anymore)
With the 1.12 release, Docker engine now includes “swarm mode” which allows Docker engines to participate in a swarm with no other external tools required.
Simply install Docker, and it is ready for you to define nodes, services, and tasks that make up your application.
While Docker Swarm and Kubernetes solve the same basic problem, Kubernetes is designed for much larger scale deployments, but has a more complicated architecture and is therefore more difficult to setup.
Docker Swarm mode uses the familiar Docker Command Line Interface (CLI) and Docker Compose to define nodes, and manage services, so the learning curve is not as steep as it is with Kubernetes.
Let’s define a few terms first:
- – Node – an instance of Docker engine
- – Tasks – the unit of scheduling in Docker
- – Services – defined and run on Nodes, and are made up of Tasks
- – swarm – a cluster of Nodes
Got it? Good.
Define nodes. Define services. Set how many nodes you want to run and where (the “desired state”), and you’re done.
The devil’s in the details, of course, but it’s still pretty simple with Docker Swarm mode. There are two types of nodes: manager nodes (which you use to define services), and worker nodes (which are told what to do by manager nodes based on your service definitions). You tell Swarm how many of each you want.
Then you submit a service definition to a manager node. The service definition consists of one or more Tasks (which are the atomic unit of scheduling in Docker Swarm mode), and how many replicas of that service you want to run on the cluster. That was easy.
The sweet spot
Because Swarm is native to Docker, there are no third party tools to worry about. Install Docker, and you have Swarm.
What about scalability? Most enterprises (including yours, probably) aren’t running server farms the size of Google (or even close). Docker Swarm can scale quite large and for many enterprises is the right tool for the job.
And Swarm uses familiar Docker APIs and tools (like the CLI) to configure it. So it’s easy to setup, and already has that great Docker smell you know and love.
Native vs 3P
Because Swarm mode is a part of Docker engine, no external tools are required (though you can still run swarm in standalone mode if you fel compelled to do so).
The familiar Docker API and tools like CLI and Compose make setup much easier (did I mention it’s open source?).
Docker with Swarm mode provides the orchestration you need, hits the sweet spot of easy setup versus feature set, and ships native with the Docker engine you’re already going to install and use anyway.
You could go with a giant, complicated tool that will let you scale your data center to 10,000 machines and handle millions of transactions per second. Thing is, you don’t really need that (okay, some of you might).
What you need is a tool that scales really really well, is easy to configure, and just works right out of the box.
Since swarm mode now ships native with Docker, you owe it to yourself to try it out. I think you’ll be pleasantly surprised at how well it performs.