简体   繁体   English

Kubernetes Nginx 多个小型 Pod vs 每个节点一个 Pod

[英]Kubernetes Nginx many small pods vs one pod per node

I am running nginx on a kubernetes cluster having 3 nodes.我在具有 3 个节点的 kubernetes 集群上运行 nginx。

I am wondering if there is any benefit of having for example 4 pods and limit their cpu/mem to approx.我想知道拥有例如 4 个 pod 并将它们的 cpu/mem 限制为大约是否有任何好处。 1/4 of the nodes capacity vs running 1 pod per node limiting cpu/mem so that pod can use resources of the whole node (for the sake of simplicity, we leave cubernet services out of the equation). 1/4 的节点容量与每个节点运行 1 个 pod 限制 cpu/mem 以便 pod 可以使用整个节点的资源(为简单起见,我们将 cubernet 服务排除在外)。

My feeling is that the fewer pods the less overhead and going for 1 pod per node should be the best in performance?我的感觉是 pod 越少开销越小,每个节点 1 个 pod 应该是性能最好的?

Thanks in advance提前致谢

With more then 1 Pod, you have a certain high availability.使用超过 1 个 Pod,您就有了一定的高可用性。 Your pod will die at one point, and if it is behind a controller (which is how is must be), it will be re-created, but you will have a small downtime.您的 pod 将在某一时刻死亡,如果它位于 controller 后面(这是必须的),它将被重新创建,但您会有一小段停机时间。

Now, take into consideration that if you deploy more then one replica of your app, even though you give it 1/n resources, there is a base image and dependencies that are going to be replicated.现在,考虑到如果您部署的应用程序的副本不止一个,即使您给它 1/n 资源,也会有一个基础映像和依赖项将被复制。

As an example, let's imagine an app that runs on Ubuntu, and has 5 dependencies:作为一个例子,让我们想象一个在 Ubuntu 上运行的应用程序,并且有 5 个依赖项:

  • If you run 1 replica of this app, you are deploying 1 Ubuntu + 5 dependencies + the app itself.如果您运行此应用程序的 1 个副本,您将部署 1 个 Ubuntu + 5 个依赖项 + 应用程序本身。

  • If you are run 4 replicas of this app, you are running 4 Ubuntus + 4*5 dependencies + 4 times the app.如果您运行此应用程序的 4 个副本,则您正在运行 4 个 Ubuntu + 4*5 依赖项 + 4 次应用程序。

My point is, if your base image would be big, and you would need heavy dependencies, it would be not a linear increase of resources.我的观点是,如果你的基础镜像很大,并且你需要大量依赖,这将不是资源的线性增长。

Performance-wise, I don't think there is much difference.在性能方面,我认为没有太大区别。 One of your nodes will be heavily bombed as all your requests will end up there, but if your nodes can handle it, there should be no problem.您的一个节点将被严重轰炸,因为您的所有请求都将在那里结束,但如果您的节点可以处理它,那么应该没有问题。

What you are referring to is the difference between horizontal and vertical scaling.您指的是水平和垂直缩放之间的区别。 Regarding vertical scaling, you would increase the resources of your application as you see fit.关于垂直扩展,您可以根据需要增加应用程序的资源。 Otherwise, you would scale horizontally by increasing the amount of replicas of your application.否则,您将通过增加应用程序的副本数量来水平扩展。

Doing one or the other depends on features that you application may or may not have.执行其中一项取决于您的应用程序可能具有或不具有的功能。 In the case of nginx scaling horizontally would split traffic per pod and also per node which would result in a better throughput for your most likely reverse proxy.在 nginx 的情况下,水平扩展将拆分每个 pod 和每个节点的流量,这将为您最有可能的反向代理带来更好的吞吐量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM