我可以理解在docker swarm中扩展容器(作为服务)的优点,这些容器分布在多个物理主机服务器上,但是在单个物理主机上扩展容器(不使用swarm)也有优势,如果可以的话这些是什么?
docker-compose scale apache=4
最佳答案
您可以在Martin Villalba的“Docker Compose: Scaling Multi-Container Applications”中看到单主机服务扩展的示例
在这种情况下,您需要注意的地方是:
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.
在那篇文章中,.Net Web应用程序可以在多个容器中扩展,并可以通过负载平衡器进行访问。
即使在单个物理主机上,也可以更好地在不同容器之间分配和分配物理机的资源。如果这些容器之一发生故障,另一个仍可以提供预期的服务。
OP paj指向他的文章“Docker Mono Host Service Scaling and Dynamic Load Balancing with NGINX”来说明这一点。
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.
他使用NGiNX http_dyups_module允许动态更新NGINX上游主机配置。
关于docker - Docker在单个主机上扩展容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44477049/