Openshift多个Pod的负载均衡是如何工作的?

huangapple go评论64阅读模式
英文:

How does openshift multiple pods loadbalancing work?

问题

在OpenShift中,我有一个包含一个Spring Boot应用程序的项目。当我发送HTTP请求时,Spring Boot应用程序会记录一条消息。我可以在OpenShift的pod日志中看到这条消息。

当我将pod扩展到两个并发送相同的HTTP请求时,只有一个pod接收并记录了该请求。当我使用JMeter发送1000个请求时,也是如此:只有一个pod接收所有请求。

OpenShift难道不负责负载均衡吗?

我尝试发送多个请求,期望这些请求在2个pod之间均衡分配。

英文:

In openshift I have a project with one Spring Boot application.
When I send a HTTP request, the Spring Boot application logs a message. I can see this message in the log of the pod in openshift.

When I scale the pod to two and send the same HTTP request, only one of the pods receives this request and logs it. This also happens when I send a 1000 requests using JMeter: only one pod receives all requests.

Doesn't openshift balance the load?

I tried sending multiple requests and expected these requests to be balanced over the 2 pods.

答案1

得分: 0

Pod traffic load balancing,不是OpenShift特定的机制。这是Kubernetes核心功能,由Service对象处理。将Service视为进入Pod的网络路径。Service将负责将流量均衡分发到多个Pod。Service将在集群内部均衡网络流量,并在需要将这个网络流量外部暴露时,依赖于Route(OpenShift特定)Ingress(Kubernetes通用)

在不了解JMeter如何访问托管在Pod中的应用程序的更多细节的情况下,很难给出明确的答案。然而,ServiceRoute公开了一些功能,用于处理Pod网络负载均衡。

有各种Route特定的注释可以控制网络的“粘性”。可能最相关的两个是haproxy.router.openshift.io/balancehaproxy.router.openshift.io/disable_cookies。还有Service会话亲和性选项。

所有这些组件共同工作,将网络流量引入您的应用程序。只有您知道您正在遵循的确切路径,并且能够调整任何必要的配置。

英文:

Pod traffic load balancing, is not an OpenShift-specific mechanism. This is a core kubernetes functionality, handled by Service objects. Consider Services as your network path into pods. The Service will handle load balancing traffic to multiple pods. Services will balance network traffic within the cluster, and when you need to expose this network traffic externally you rely on Routes (OpenShift-specific) or Ingresses (kubernetes-generic).

Without knowing more specifics about how JMeter is accessing the application hosted in the pods, it's difficult to give a solid answer. However, there are several functionalities that Services and Routes expose to address pod network load balancing.

There are various Route-specific annotations that can control network "stickiness". Probably the two most relevant ones are haproxy.router.openshift.io/balance and haproxy.router.openshift.io/disable_cookies. There are also Service session affinity options as well.

All of these components work together to get network traffic into your application. And only you know the exact path that you're following and able to adjust any necessary configurations as such.

huangapple
  • 本文由 发表于 2023年5月14日 03:04:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76244455.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定