Search code examples
dockerdocker-swarm

Docker scaling containers on a single host


I can understand the advantages of scaling containers (as a service) in a docker swarm where the containers are distributed over multiple physical host servers, but are there also advantages to scaling containers (not using swarm) on a single physical host, and if so what are they?

docker-compose scale apache=4

Solution

  • You can see an example of mono-host service scaling in "Docker Compose: Scaling Multi-Container Applications", by Martin Villalba

    Where you need to be careful in this scenario is:

    ensure that the service we want to scale does not specify the external/host port. If we specify that port, the service cannot be scaled since all the instances would try to use the same host port.

    In that article, a .Net web application is scale in multiple containers, and reached through a load balancer.

    Even on a single physical host, that would allow to better allocate and divide the resources of the physical machine between the different container. If one of those containers fails, the other can still provide the expected service.


    The OP paj points to his article "Docker Mono Host Service Scaling and Dynamic Load Balancing with NGINX" illustrating this.

    are there any benefits from scaling a service in mulitple containers on a single host?

    Well, yes, because you can still load balance the traffic to your application and achieve a basic level of container resilience.

    He uses the NGiNX http_dyups_module which allows to dynamically update the NGINX upstream host configuration.