Increasing the Listening Queue Length by Configuring Container Kernel Parameters
Application Scenarios
By default, the listening queue (backlog) length of net.core.somaxconn is set to 128. If the number of connection requests surpasses this limit during busy services, new requests will be declined. To avoid this issue, you can adjust the kernel parameter net.core.somaxconn to increase the length of the listening queue.
Procedure
- Modify kubelet configuration in the target node pool (only for clusters of v1.15 or later).
- Log in to the CCE console and click the cluster name to access the cluster console.
- Locate the row containing the target node pool and choose More > Manage.
Figure 1 Managing node pool configuration
- Modify kubelet configuration parameters and add [net.core.somaxconn] to Allowed unsafe sysctls.
Figure 2 Modifying kubelet parameters
- Create a workload, set kernel parameters, and configure the affinity with the node in 1.
apiVersion: apps/v1 kind: Deployment metadata: annotations: description: '' labels: appgroup: '' name: test1 namespace: default spec: replicas: 1 selector: matchLabels: app: test1 template: metadata: annotations: metrics.alpha.kubernetes.io/custom-endpoints: '[{"api":"","path":"","port":"","names":""}]' labels: app: test1 spec: containers: - image: 'nginx:1.14-alpine-perl' name: container-0 resources: requests: cpu: 250m memory: 512Mi limits: cpu: 250m memory: 512Mi imagePullSecrets: - name: default-secret securityContext: sysctls: - name: net.core.somaxconn value: '3000' affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - 192.168.x.x # Node name.
- Go to the container and check whether the parameter settings take effect.
kubectl exec -it <pod name> -- /bin/sh
Run the following command in the container to check whether the configuration takes effect:
sysctl -a |grep somax
Figure 3 Viewing the parameter configuration
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot