简体   繁体   English

副本会减少单节点 kubernetes 集群上的流量吗?

[英]do replicas decrease traffic on a single node kubernetes cluster?

I am new to the world of kubernetes.我是 kubernetes 世界的新手。 I am trying to implement kubernetes advantages on my personal project.我正在尝试在我的个人项目中实现 kubernetes 的优势。

I have an api service in a docker container which fetches data from back end.我在 docker 容器中有一个 api 服务,它从后端获取数据。

I plan on creating multiple replicas of this api service container on a single external port in the kubernetes cluster.我计划在 kubernetes 集群的单个外部端口上创建这个 api 服务容器的多个副本。 Do replicas share traffic if they're on a single node ?如果副本位于单个节点上,它们是否共享流量?

My end goal is to create multiple instances of this api service to make my application faster(users can access one of the multiple api services which should reduce traffic on a single instance).我的最终目标是创建这个 api 服务的多个实例,以使我的应用程序更快(用户可以访问多个 api 服务之一,这应该减少单个实例上的流量)。

Am i thinking right in terms of kubernetes functionality?我在 kubernetes 功能方面的想法是否正确?

You are right, the multiple replicas of your API service will share the load.您是对的,您的 API 服务的多个副本将分担负载。 In Kubernetes, there is a concept of Services which will send traffic to the backend and in this case it is your api application running in the pods.在 Kubernetes 中,有一个服务的概念,它会将流量发送到后端,在这种情况下,它是在 pod 中运行的 api 应用程序。 By default, the choice of backend is random.默认情况下,后端的选择是随机的。 Also, it doesn't matter whether the Pods are running on a single node or on different nodes, the traffic will be distributed randomly among all the Pods based on the labels .此外,无论 Pod 是在单个节点上还是在不同节点上运行,流量都将根据标签随机分布在所有 Pod 中。

This will also make your application highly available because you will use deployment for specifying the number of replicas and whenever the number of available replicas are less than the desired replicas, Kubernetes will provision new pods to meet the desired state.这也将使您的应用程序高度可用,因为您将使用部署来指定副本数量,并且每当可用副本数量少于所需副本时,Kubernetes 将提供新的 pod 以满足所需状态。

If you add multiple instances / replicas of your web server it will share the load and will avoid single point of failure.如果您添加 Web 服务器的多个实例/副本,它将分担负载并避免单点故障。

However to achieve this you will have to create and expose a Service.但是,要实现这一点,您必须创建并公开一个服务。 You will have to communicate using the Service endpoint and not using each pods IP directly.您必须使用 Service 端点进行通信,而不是直接使用每个 pods IP。

A service exposes an endpoint.服务公开一个端点。 It has load balancing.它具有负载平衡。 It usually uses round robin to distribute load / requests to servers behind the service load balancer.它通常使用循环将负载/请求分发到服务负载均衡器后面的服务器。

Kubernetes manages Pods. Kubernetes 管理 Pod。 Pods are wrappers around containers. Pod 是容器的包装器。 Kubernetes can schedule multiple pods on the same node(hardware) or across multiple nodes. Kubernetes 可以在同一个节点(硬件)或跨多个节点调度多个 pod。 Depends how you configure it.取决于你如何配置它。 You can use Deployments to manage ReplicaSets which manage Pods.您可以使用 Deployment 来管理管理 Pod 的 ReplicaSet。

Usually it is recommended to avoid managing pods directly.通常建议避免直接管理 Pod。 Pods can crash, stop abruptly. Pod 可能会崩溃,突然停止。 Kubectl will create a new for you automatically depending on the Replica Set config. Kubectl 将根据副本集配置自动为您创建一个新的。

Using deployments you can do rolling updates also.使用部署,您还可以进行滚动更新。

You can refer to Kubernetes Docs to read about this in detail.你可以参考Kubernetes Docs来详细阅读。

Yes.是的。 It's called Braess's paradox .这就是所谓的布雷斯悖论

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

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