为 GKE 上的节点配置 net.core.somaxconn
Configure net.core.somaxconn for Nodes on GKE
我们有一个 Python uWSGI REST API 服务器来处理很多调用。当 api 通过外部资源调用高峰时,队列立即被填满,因为 uWSGI 队列大小默认设置为 100。经过一番挖掘,我们发现这是根据服务器的 net.core.somaxconn 设置。而在 Kubernetes 的情况下,因为节点的设置。
我们发现此文档使用 sysctl 来更改 net.core.somaxconn。 https://kubernetes.io/docs/concepts/cluster-administration/sysctl-cluster/
但这不适用于 GKE,因为它需要 docker 1.12 或更新版本。
我们也发现了这个片段,但看起来真的很老套。
https://github.com/kubernetes/contrib/blob/master/ingress/controllers/nginx/examples/sysctl/change-proc-values-rc.yaml
DaemonSet 不是比配套容器更好吗?
在节点池的所有节点上将 net.core.somaxconn 设置为高于默认值的最佳做法是什么?
一个好的方法是使用具有特权的守护进程集,因为它会在所有现有节点和新节点上 运行。
只需使用提供的启动容器,例如:
https://github.com/kubernetes/contrib/blob/master/startup-script/startup-script.yml
针对您的情况:
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: startup
spec:
updateStrategy:
type: RollingUpdate
template:
spec:
hostPID: true
containers:
- name: system-tweak
image: gcr.io/google-containers/startup-script:v1
imagePullPolicy: Always
securityContext:
privileged: true
env:
- name: STARTUP_SCRIPT
value: |
#! /bin/bash
echo 32768 > /proc/sys/net/core/somaxconn
我们有一个 Python uWSGI REST API 服务器来处理很多调用。当 api 通过外部资源调用高峰时,队列立即被填满,因为 uWSGI 队列大小默认设置为 100。经过一番挖掘,我们发现这是根据服务器的 net.core.somaxconn 设置。而在 Kubernetes 的情况下,因为节点的设置。
我们发现此文档使用 sysctl 来更改 net.core.somaxconn。 https://kubernetes.io/docs/concepts/cluster-administration/sysctl-cluster/ 但这不适用于 GKE,因为它需要 docker 1.12 或更新版本。
我们也发现了这个片段,但看起来真的很老套。 https://github.com/kubernetes/contrib/blob/master/ingress/controllers/nginx/examples/sysctl/change-proc-values-rc.yaml DaemonSet 不是比配套容器更好吗?
在节点池的所有节点上将 net.core.somaxconn 设置为高于默认值的最佳做法是什么?
一个好的方法是使用具有特权的守护进程集,因为它会在所有现有节点和新节点上 运行。 只需使用提供的启动容器,例如:
https://github.com/kubernetes/contrib/blob/master/startup-script/startup-script.yml
针对您的情况:
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: startup
spec:
updateStrategy:
type: RollingUpdate
template:
spec:
hostPID: true
containers:
- name: system-tweak
image: gcr.io/google-containers/startup-script:v1
imagePullPolicy: Always
securityContext:
privileged: true
env:
- name: STARTUP_SCRIPT
value: |
#! /bin/bash
echo 32768 > /proc/sys/net/core/somaxconn