Skip to content

config: Introduce new Cgroups config

John Cai requested to merge jc-cgroups-improved-config into master

Introduce a new config that will changes the way cgroups work. The design has been discussed in !4461 (merged). This change maintains backwards compatibility with the old format and includes no changes in logic. A future commit will make use of this new cgroups configuration.

Here is the top level [cgroups] configuration:

[cgroups]
mountpoint = "/sys/fs/cgroup"
hierarchy_root = "gitaly"
memory_bytes = 64424509440
cpu_shares = 1024

mountpoint is the top level directory where cgroups will be created.

hierarchy_root is the parent cgroup under which Gitaly creates cgroups.

memory_bytes limits all processes created by Gitaly to a memory limit, collectively. 0 implies no limit.

cpu_shares limits all processes created by Gitaly to a cpu limit, collectively. 0 implies no limit.

Cgroups that have a repository-level isolation can also be defined:

[cgroups.repositories]
count = 10000
memory_bytes = 12884901888 // 12gb
cpu_shares = 512

count is the number of cgroups to create.

memory_bytes limits memory for processes within one cgroup. This number cannot exceed the top level memory limit.

cpu_shares limits cpu for processes within one cgroup. This number cannot exceed the top level memory limit.

These cgroups will be created when Gitaly starts up. A circular hashing algorithm is used to assign repositories to cgroups. So when we reach the max number of cgroups we set in [cgroups.repositories], requests from subsequent repositories will be assigned to an existing cgroup.

Changelog: changed

Edited by John Cai

Merge request reports