A quota group sets resource limits on services inside the snaps it contains. Currently, only maximum memory is supported as a resource limit.
Quota groups are created, removed and queried with the following snap commands:
- set-quota: create or update a quota group
- quota: show quota group for a set of snaps
- quotas: show all quota groups
- remove-quota: remove a quota group
Quota groups require snap version 2.52 and they’re currently considered experimental. To experiment with quota groups, an experimental feature-flag must be first enabled:
$ sudo snap set system experimental.quota-groups=true
- Creating a quota group
- Adding snaps to a quota group
- Nested quota groups
- Group members and resource usage
- Removing snaps and quota groups
Creating a quota group
To create a quota group, use the set-quota command with a group name as an argument and
--memory=<amount> to set a maximum memory resource limit.
Memory units can be ‘B’, ‘KB’, 'MB or ‘GB’ with a size greater than 4KB:
$ sudo snap set-quota highmem --memory=2GB
If the group already exists, set-quota will update its resource limit.
The memory limit for a quota group can only be increased. Increasing the memory limit for a quota group does not restart any services associated with snaps in the quota group.
To decrease the memory limit for a quota group, the entire group must be removed with the remove-quota command and recreated with a lower limit.
Use the quotas command to view created quota groups:
$ snap quotas Quota Parent Constraints Current highmem memory=2.00GB
Snaps can belong to only one quota group, but quota groups can be nested.
Nested quota groups
To create a nested quota group, add the
--parent=<parent group> argument to the set-quota command when creating a new quota group:
$ sudo snap set-quota lowmem --memory=1GB --parent=highmem
The quotas command will also show nested quota groups:
$ snap quotas Quota Parent Constraints Current highmem memory=2.00GB lowmem highmem memory=1.00GB
The total resource use of nested quota groups cannot exceed that of the parent group.
Adding snaps to a quota group
Add the names of one or more snaps to the set-quota command to include those snaps in the quota group when its created:
$ sudo snap set-quota lowmem go-example-webserver --parent=highmem
If the quota group already exists, snaps can be added by using set-quota without the resource limit:
$ sudo snap set-quota lowmem go-example-webserver
Adding new a snap to a quota group will result in all non-disabled services in
that snap being restarted.
Group members and resource usage
The quota command shows information about a quota group, including the set of
snaps it includes and any subgroups it contains, as well as its resource constraints and
the current usage of those constrained resources by snap services in those snaps:
$ snap quota lowmem name: lowmem parent: highmem constraints: memory: 1.00GB current: memory: 5.32MB snaps: - go-example-webserver
Use the quota command on the parent of any nested groups to view total resource usage and subgroups:
$ snap quota highmem name: highmem constraints: memory: 2.00GB current: memory: 5.35MB subgroups: - lowmem
Removing snaps and quota groups
To remove a snap from a quota group, the entire group must be removed with the remove-quota command and the quota group recreated without the snaps:
$ sudo snap remove-quota lowmem $ sudo snap set-quota lowmem --memory=1GB $ snap quota lowmem name: lowmem constraints: memory: 1.00GB current: memory: 0B
Currently, only quota groups with no subgroups can be removed. In order to remove a quota group with subgroups, the subgroups must be first removed until there are no further subgroups in the group, then the group itself can be removed.
An existing subgroup cannot be moved from one parent to another.
To remove a subgroup from a quota group, the subgroup must be first removed directly with the remove-quota command.
Last updated 3 months ago.