Docker 在单个主机上扩展容器

Docker scaling containers on a single host

我可以理解在容器分布在多个物理主机服务器上的 docker 集群中扩展容器(作为服务)的优势,但扩展容器(不使用集群)也有优势在单个物理主机上,如果是,它们是什么?

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 points to his article "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 上游主机配置。