簡體   English   中英

Kubernetes 請求不平衡

[英]Kubernetes requests not balanced

我們的 kubernetes 集群的流量剛剛增加,我注意到在我們的 6 個應用程序 pod 中,其中 2 個似乎沒有被經常使用。 kubectl top pods返回以下內容

CPU使用率

您可以看到 6 個 pod,其中 4 個使用了超過 50% 的 CPU(2 個 vCPU 節點),但其中兩個實際上並沒有做太多事情。

我們的集群是在 AWS 上設置的,使用 ALB 入口控制器。 負載平衡器被配置為使用Least outstanding requests而不是Round robin ,以嘗試平衡更多的事情,但我們仍然看到這種不平衡。

有什么方法可以確定為什么會發生這種情況,或者是否確實存在問題? 我希望這是正常行為而不是問題,但我寧願調查它。

應用部署配置

這是主要應用程序 pod 的配置。 真的沒什么好看的

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "app.fullname" . }}
  labels:
    {{- include "app.labels" . | nindent 4 }}
    app.kubernetes.io/component: web
spec:
  replicas: {{ .Values.app.replicaCount }}
  selector:
    matchLabels:
      app: {{ include "app.fullname" . }}-web

  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/config_maps/app-env-vars.yaml") . | sha256sum }}
      {{- with .Values.podAnnotations }}
        {{- toYaml . | nindent 10 }}
      {{- end }}
      labels:
        {{- include "app.selectorLabels" . | nindent 8 }}
        app.kubernetes.io/component: web
        app: {{ include "app.fullname" . }}-web
    spec:
      serviceAccountName: {{ .Values.serviceAccount.web }}
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - {{ include "app.fullname" . }}-web
              topologyKey: failure-domain.beta.kubernetes.io/zone
      containers:
        - name: {{ .Values.image.name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          command:
            - bundle
          args: ["exec", "puma", "-p", "{{ .Values.app.containerPort }}"]
          ports:
            - name: http
              containerPort: {{ .Values.app.containerPort }}
              protocol: TCP
          readinessProbe:
            httpGet:
              path: /healthcheck
              port: {{ .Values.app.containerPort }}
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 5
            timeoutSeconds: 5
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
          envFrom:
          - configMapRef:
              name: {{ include "app.fullname" . }}-cm-env-vars

          - secretRef:
              name: {{ include "app.fullname" . }}-secret-rails-master-key

          - secretRef:
              name: {{ include "app.fullname" . }}-secret-db-credentials

          - secretRef:
              name: {{ include "app.fullname" . }}-secret-db-url-app

          - secretRef:
              name: {{ include "app.fullname" . }}-secret-redis-credentials

這是 Kubernetes 的一個已知問題。
簡而言之,Kubernetes 不會對長期存在的 TCP 連接進行負載平衡。
這篇優秀的文章詳細介紹了它。

您所服務的負載分布與案例完全相符。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM