简体   繁体   中英

Why do I have so many duplicated processes?

I'm stressing my kubernetes API and I found out that every request is creating a process inside the Worker Node.

Deployment YAML :

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ${KUBE_APP_NAME}-deployment
  namespace: ${KUBE_NAMESPACE}
  labels:
    app_version: ${KUBE_APP_VERSION}
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  selector:
    matchLabels:
      app_name: ${KUBE_APP_NAME}
  template:
    metadata:
      labels:
        app_name: ${KUBE_APP_NAME}
    spec:
      containers:
        - name: ${KUBE_APP_NAME}
          image: XXX:${KUBE_APP_VERSION}
          imagePullPolicy: Always
          env:
            - name: MONGODB_URI
              valueFrom:
                secretKeyRef:
                  name: mongodb
                  key: uri
            - name: JWT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: jwt
                  key: password
          ports:
            - containerPort: 80
          resources:
            requests:
              memory: "64Mi"
              cpu: "250m"
            limits:
              memory: "128Mi"
              cpu: "500m"
      imagePullSecrets:
        - name: regcred

Apache Bench used ab -p payload.json -T application/json -c 10 -n 2000

Why is this?

htop 截图

It's hard to answer your questions if this is normal that the requests are being kept open. We don't know what exactly is your payload and how big it is. We also don't know if the image that you are using is handling those correctly.

You should use verbose=2 ab -v2 <host> and check what it taking so long.

You are using Apache Bench with -c 10 -n 2000 options which means there will be:

  • -c 10 concurrent connections at a time,
  • -n 2000 request total

You could use -k to enable HTTP KeepAlive

-k

Enable the HTTP KeepAlive feature, ie , perform multiple requests within one HTTP session. Default is no KeepAlive.

It would be easier if you provided the output of using the ab .

As for the Kubernetes part.

We can read a definition of a pod available at Viewing Pods and Nodes :

A Pod is a Kubernetes abstraction that represents a group of one or more application containers (such as Docker or rkt), and some shared resources for those containers... The containers in a Pod share an IP Address and port space, are always co-located and co-scheduled, and run in a shared context on the same Node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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