This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
технология_cgroup [2020/07/20 07:22] val |
технология_cgroup [2024/12/11 10:58] (current) val [cgroup v2] |
||
---|---|---|---|
Line 2: | Line 2: | ||
* [[https://habrahabr.ru/company/selectel/blog/303190/|Механизмы контейнеризации: cgroups]] (сокращение от control groups, контрольные группы) | * [[https://habrahabr.ru/company/selectel/blog/303190/|Механизмы контейнеризации: cgroups]] (сокращение от control groups, контрольные группы) | ||
- | * [[https://blogs.rdoproject.org/7761/hands-on-linux-sandbox-with-namespaces-and-cgroups|Hands on Linux sandbox with namespaces and cgroups]] | + | * [[https://habr.com/ru/companies/redhatrussia/articles/423051/|Борьба за ресурсы, часть 1: Основы Cgroups]] |
+ | |||
+ | ===== cgroup v2 ===== | ||
+ | |||
+ | * [[https://pavlokhmel.com/cgroup-v2-limit-memory-and-cpu-usage-for-all-users-on-linux.html|Cgroups v2 - limit memory and CPU usage for all users on Linux]] | ||
+ | |||
+ | <code> | ||
+ | # ###systemd-run --scope -p MemoryMax=1M vim | ||
+ | |||
+ | # lssubsys -a | ||
+ | |||
+ | # systemd-cgls | ||
+ | /apache2 | ||
+ | |||
+ | # cat /sys/fs/cgroup/system.slice/apache2.service/memory.high | ||
+ | |||
+ | # echo 2000000 > /sys/fs/cgroup/system.slice/apache2.service/memory.high | ||
+ | |||
+ | # time curl 127.0.0.1 | ||
+ | |||
+ | # systemctl edit --force --full my.slice | ||
+ | </code><code> | ||
+ | [Unit] | ||
+ | Description=My Slice | ||
+ | Before=slices.target | ||
+ | |||
+ | [Slice] | ||
+ | MemoryAccounting=true | ||
+ | MemoryLimit=64M | ||
+ | MemoryHigh=64M | ||
+ | CPUAccounting=true | ||
+ | CPUQuota=5% | ||
+ | TasksMax=4096 | ||
+ | </code><code> | ||
+ | # systemctl edit apache2.service | ||
+ | </code><code> | ||
+ | [Service] | ||
+ | Slice=my.slice | ||
+ | </code><code> | ||
+ | # systemctl daemon-reload | ||
+ | |||
+ | # systemctl restart apache2.service | ||
+ | |||
+ | # systemd-cgls | ||
+ | /apache2 | ||
+ | |||
+ | # cat /sys/fs/cgroup/my.slice/memory.high | ||
+ | |||
+ | # cat /sys/fs/cgroup/my.slice/cpu.max | ||
+ | </code> | ||
+ | ===== cgroup v1 (Debian10/Ubuntu20) ===== | ||
<code> | <code> |