Limiter les ressources CPU pour un process donne

Restreindre l'usage de CPU

How to limit CPU Usage of a process

Voir :

https://wiki.archlinux.org/index.php/cgroups

https://linuxfr.org/users/zezinho/journaux/les-cgroups-un-outil-trop-meconnu

https://linuxhint.com/limit_cpu_usage_process_linux/

nice -n 19 COMMAND

ou

renice +19 1234 #ionice -c3 -p 1234

Ou encode

systemd-run -p IOWeight=10 updatedb

Exemple

# best effort, highest priority sudo ionice -c2 -n0 -p `pgrep etcd`
cgcreate -g cpu:/cpulimit cgset -r cpu.cfs_period_us=1000000 cpulimit cgset -r cpu.cfs_quota_us=100000 cpulimit

check

cgget -g cpu:cpulimit
cgexec -g cpu:cpulimit COMMAND

ou

echo 1234 > /sys/fs/cgroup/cpu/cpulimit/tasks

ou

#cpulimit -p <PID> -l <%CPU> cpulimit -p 1234 -l 80

Pb

write error: No space left on device

Erreur

# echo 1234 > /sys/fs/cgroup/cpuset/cpulimit/tasks
-bash: echo: write error: No space left on device

Solution

echo 0 > /sys/fs/cgroup/cpuset/cpulimit/cpuset.mems echo 0 > /sys/fs/cgroup/cpuset/cpulimit/cpuset.cpu

How to limit a process to one CPU core in Linux - CPU affinity

start a command with the given affinity

taskset -c 0 mycommand --option

set the affinity of a running process

taskset -c -pa 0 1234