Skip to content

User Cgroups

This feature relies on cgroups v2, which is a kernel option.

To set a limit to "unlimited", pass a limit with blank value. Setting a limit to be blank tells the system it should be unlimited..

Enable

See the full install guide here

Debian 11 will have it enabled in the kernel by default.

CentOS 8, Debian 10, and older, will need to have it turned on in the kernel (requires reboot)

bash
cd /usr/local/directadmin/custombuild
./build grub_conf
./build apache
./build php n

Anything older does not support cgroups.

DirectAdmin will hide or ignore values if the system has not created: /sys/fs/cgroup/user.slice

JSON Packages

Show package:

CMD_SHOW_USER_PACKAGE?package=gold&json=yes
CMD_SHOW_RESELLER_PACKAGE?package=gold&json=yes

New array, eg:

	"cgroup": 
	{
		"options": 
		{
			"CPUQuota": 
			{
				"cgroup_type": "percent",
				"default": "",
				"desc": "Percent of CPU Core. >100% for more cores.",
				"name": "CPUQuota",
				"placeholder": "400%",
				"string": "CPU Quota",
				"type": "text"
			},
			"IOReadBandwidthMax": 
			{
				"cgroup_type": "io",
				"default": "",
				"desc": "Max rate data can be read from a disk.",
				"minimum": "256K",
				"name": "IOReadBandwidthMax",
				"placeholder": "5M",
				"string": "IO Read Bandwidth Max",
				"type": "text"
			},
			"IOReadIOPSMax": 
			{
				"cgroup_type": "iops",
				"default": "",
				"desc": "Max disk read operations per second.",
				"minimum": "256",
				"name": "IOReadIOPSMax",
				"placeholder": "1K",
				"string": "IOPS Read Max",
				"type": "text"
			},
			"IOWriteBandwidthMax": 
			{
				"cgroup_type": "io",
				"default": "",
				"desc": "Max rate data can be written to a disk.",
				"minimum": "256K",
				"name": "IOWriteBandwidthMax",
				"placeholder": "5M",
				"string": "IO Write Bandwidth Max",
				"type": "text"
			},
			"IOWriteIOPSMax": 
			{
				"cgroup_type": "iops",
				"default": "",
				"desc": "Max disk write operations per second.",
				"minimum": "256",
				"name": "IOWriteIOPSMax",
				"placeholder": "1K",
				"string": "IOPS Write Max",
				"type": "text"
			},
			"MemoryHigh": 
			{
				"cgroup_type": "bytes",
				"default": "",
				"desc": "Throttle Memory above this limit.",
				"name": "MemoryHigh",
				"placeholder": "1G",
				"string": "Memory High",
				"type": "text"
			},
			"TasksMax": 
			{
				"cgroup_type": "int",
				"default": "",
				"desc": "Max Tasks that may be created in the unit",
				"minimum": "5",
				"name": "TasksMax",
				"placeholder": "4915",
				"string": "Tasks Max",
				"type": "text"
			}
		},
		"saved": 
		{
			"CPUQuota": 
			{
				"cgroup_type": "percent",
				"default": "",
				"desc": "Percent of CPU Core. >100% for more cores.",
				"name": "CPUQuota",
				"placeholder": "400%",
				"string": "CPU Quota",
				"type": "text",
				"value": "400%"
			}
		}
	},

Where options are what can be used, with info about the item.. and saved is which of those items actually exist in the package, including the value. Items that have a minimum are enforced at the back-end and blocks the save entirely (Creation/Modification)

Option variables

Each group option will have items:

  • cgroup_type: see below. The specific format for a given option.
  • default: the default value, usually blank (unlimited)
  • desc: longer description, translated in the internal gettext
  • name: the form name to pass, matches the system's cgroup option name.
  • placeholder: for empty inputs, an example/background text
  • string: the human readable name (shorter), translated in the internal gettext
  • type:text form field type (eg: future might have checkbox, for example, no others for now)
  • value: Only for saved values in the package itself.

options vs saved does have mostly redundant info. Essentially, just the "value" will exist for the saved array.

Package Defaults:

CMD_SHOW_USER_PACKAGE?package=unlimited
CMD_SHOW_RESELLER_PACKAGE?package=unlimited

Same as listing a specific package, but the "saved" array will not be passed, since it's just the default list.

Save Package

CMD_MANAGE_USER_PACKAGES
CMD_MANAGE_RESELLER_PACKAGES
method: POST
plus all new values.

To set an option to be "unlimited", it must be set with a blank value. Eg:

CPUQuota=

will removing any cpu limits.

As before, all values must be sent when saving a package. The requirement to save these options is not required, but saving them once, then not passing them later, will not delete them from User settings. cgroup settings are not "deleted" from the system, they must be saved to unlimited (blank value) to remove the limits.

Cgroup types

DA uses a variable called: cgroup_type, as defined:

percent: 1% - 10000%
int: 1 - 1000000
bytes: 1, 2K, 5M, 2G, 3T
io: same as "bytes", but internally DA adds the list of devices to the value.  Packages/Users only set the number, not the device, eg: IOReadBandwidthMax=5M
iops: same as "io"

Users

Create/Modify Users/Resellers use the same formatting as packages. Pass the values you'd like to set during:

  • Custom User Creation (CMD_ACCOUNT_USER, without setting package)
  • User Modification (CMD_MODIFY_USER/CMD_MODIFY_RESELLER)
  • Show User: CMD_SHOW_USER?user=fred&json=yes

Reseller

When setting Cgroup values for a Reseller, they're saved into that Resller's reseller.conf file. The values set here are optional. If they are blank, the Reseller is free to set (or not set) values for their Users as desired. If they are set, then the value set is the maximum any of the Reseller's Users can have. For example, if the reseller.conf has: CPUQuota=400%

This implies that any User under this Reseller must have a CPUQuota set (cannot be blank) and it must not exceed 400%. All Users under the Reseller can have at most CPUQuota=400%. This is different than the other cumulative values, like bandwidth or disk usage, where the Users are added together. This is not like that.. the values are the max for each User.

Global tokens

"HAVE_CGROUP": "yes",

"CGROUP_CPUQuota": "25%",
"CGROUP_IOReadBandwidthMax": "1M",
"CGROUP_IOReadIOPSMax": "256",
"CGROUP_IOWriteBandwidthMax": "1M",
"CGROUP_IOWriteIOPSMax": "",
"CGROUP_MemoryHigh": "128M",
"CGROUP_TasksMax": "5",

If any value is unset or blank, it'll always be set here, with the value of ""