What is the kernel.pid_max parameter and how can a low value affect it?
sobes.tech AI
Answer from AI
The kernel.pid_max parameter in Linux defines the maximum process ID (PID) value that can be assigned to a process in the system. By default, this value is usually around 32768 or higher, but it can be increased to several million.
If kernel.pid_max is set too low, it limits the number of processes that can exist simultaneously in the system. As a result, when this limit is reached, new processes cannot be created, leading to startup errors and potential service hangs.
For example, if you have many parallel tasks or containers, and pid_max is too small, the system will quickly exhaust available PIDs, negatively affecting stability.
You can check the current value with the command:
cat /proc/sys/kernel/pid_max
To temporarily change it (until reboot):
sudo sysctl -w kernel.pid_max=131072
For permanent changes, add the following to /etc/sysctl.conf:
kernel.pid_max = 131072
It is recommended to set the value with a margin, considering the load and the number of processes in the system.