PeterKogo
PeterKogo

Reputation: 121

Change cgroup pid.max value?

I am currently tracing cannot fork() errors on my Ubuntu Server and I was able to pinpoint it to the pid.max value of 700 under /sys/fs/cgroup/pids/. However, I can only able to set the values /system.slice/pids.max and /user.slice/pids.max - not pids.max. Plus, these reset after reboot to the value max which again enforces the global pids.max value.

Is it possible to simply change the it from 700 to something higher? root + sudo were of no help.

Is there another way to override this value?

Upvotes: 3

Views: 6783

Answers (2)

PeterKogo
PeterKogo

Reputation: 121

After a long back and forth with my server hoster, they finally spilled the beans.

I was renting a V-Server with very beefy hardware for very little money. The catch? You can only run 700 concurrent tasks. That's where the pids.max value came from and overruled the TasksMax and numprocs values.

Upvotes: 4

Frantisek Sumsal
Frantisek Sumsal

Reputation: 126

I think you're looking for DefaultTasksMax= directive from /etc/systemd/system.conf.

You can check the runtime value by issuing systemctl show -p DefaultTasksMax:

$ systemctl show -p DefaultTasksMax
DefaultTasksMax=19096

If you wish to change it, simply edit the respective directive line in /etc/systemd/system.conf. Similar directive (TasksMax=) exists to tweak this setting on per-unit basis.

Relevant documentation[0][1] snippets:

TasksMax=N

Specify the maximum number of tasks that may be created in the unit. This ensures that the number of tasks accounted for the unit (see above) stays below a specific limit. This either takes an absolute number of tasks or a percentage value that is taken relative to the configured maximum number of tasks on the system. If assigned the special value "infinity", no tasks limit is applied. This controls the "pids.max" control group attribute. For details about this control group attribute, see Process Number Controller.

The system default for this setting may be controlled with DefaultTasksMax= in systemd-system.conf(5).

DefaultTasksMax=

Configure the default value for the per-unit TasksMax= setting. See systemd.resource-control(5) for details. This setting applies to all unit types that support resource control settings, with the exception of slice units. Defaults to 15%, which equals 4915 with the kernel's defaults on the host, but might be smaller in OS containers.

Upvotes: 2

Related Questions