Comparison with Docker Swarm

Comparison between Kubernetes resource management and the Docker Swarm equivalent.


Resource management can be divided into a few categories. We need to define how much memory and CPU we expect a container will use and what the limits are. This information is crucial for a scheduler to make suitable decisions when calculating where to place containers. In this aspect, there is no essential difference between Kubernetes and Docker Swarm. Both are using requested resources to decide where to deploy containers and limits on when to evict them. Both of them are, more or less, the same in this aspect. Consider the following questions:

  1. How can we know how much memory and CPU to dedicate to each of our containers?

That’s one of the questions we hear way too many times. The answer is simple. Collect metrics, evaluate them, adjust resources, take a break, repeat.

  1. Where do we collect metrics?

We can collect metrics from wherever we want. However, Prometheus is a good choice.

  1. Where will it get metrics?

Well, it depends on which scheduler you use. If it’s Docker Swarm, you’ll need to run a bunch of exporters. Or, you might try the experimental feature that exposes Docker’s internal metrics in Prometheus format. You might even be enthusiastic enough to think they will be enough for all your monitoring and alerting needs. Maybe, by the time you read this, the feature is not experimental anymore. On the other hand, Kubernetes has it all and so much more. You can use Metrics Server, or you might discover that it is too limiting and configure Prometheus to scrape metrics directly from the Kubernetes API. Kubernetes exposes a vast amount of data. You will be able to fetch memory, CPU, IO, network, and a myriad of other metrics and make intelligent decisions not only about the resources your containers require but about so much more.

To make things clear, you can get the same metrics no matter whether you’re running Kubernetes or Docker Swarm. The major difference is that Kubernetes exposes them through its API. With Swarm, however, you’ll have to struggle between the decisions of whether to use its limited metrics or go into the trouble of setting up the exporters like cAdvisor and Node Exporter. You’ll most likely discover that you’ll need both the metrics from Swarm’s API and those from the exporters. Kubernetes has a more robust solution, even though you might still need an exporter or two. Still, having most metrics we’ll need directly from the API is extremely useful…

Get hands-on with 1200+ tech skills courses.