tech:limiter_les_ressources_cpu_pour_un_process_donne
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédente | |||
| tech:limiter_les_ressources_cpu_pour_un_process_donne [2025/10/17 16:25] – Jean-Baptiste | tech:limiter_les_ressources_cpu_pour_un_process_donne [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Limiter les ressources CPU pour un process donne | ||
| + | |||
| + | Restreindre l' | ||
| + | |||
| + | How to limit CPU Usage of a process | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | ~~~bash | ||
| + | nice -n 19 COMMAND | ||
| + | ~~~ | ||
| + | ou | ||
| + | ~~~bash | ||
| + | renice +19 1234 | ||
| + | #ionice -c3 -p 1234 | ||
| + | ~~~ | ||
| + | |||
| + | Ou encode | ||
| + | ~~~bash | ||
| + | systemd-run -p IOWeight=10 updatedb | ||
| + | ~~~ | ||
| + | |||
| + | Exemple | ||
| + | ~~~bash | ||
| + | # best effort, highest priority | ||
| + | sudo ionice -c2 -n0 -p `pgrep etcd` | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | cgcreate -g cpu:/ | ||
| + | cgset -r cpu.cfs_period_us=1000000 cpulimit | ||
| + | cgset -r cpu.cfs_quota_us=100000 cpulimit | ||
| + | ~~~ | ||
| + | |||
| + | check | ||
| + | ~~~bash | ||
| + | cgget -g cpu: | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | cgexec -g cpu: | ||
| + | ~~~ | ||
| + | |||
| + | ou | ||
| + | ~~~bash | ||
| + | echo 1234 > / | ||
| + | ~~~ | ||
| + | |||
| + | ou | ||
| + | ~~~bash | ||
| + | #cpulimit -p <PID> -l < | ||
| + | cpulimit -p 1234 -l 80 | ||
| + | ~~~ | ||
| + | |||
| + | ## Pb | ||
| + | |||
| + | ### write error: No space left on device | ||
| + | |||
| + | Erreur | ||
| + | ~~~ | ||
| + | # echo 1234 > / | ||
| + | -bash: echo: write error: No space left on device | ||
| + | ~~~ | ||
| + | |||
| + | Solution | ||
| + | ~~~bash | ||
| + | echo 0 > / | ||
| + | echo 0 > / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ## How to limit a process to one CPU core in Linux - CPU affinity | ||
| + | |||
| + | start a command with the given affinity | ||
| + | ~~~bash | ||
| + | taskset -c 0 mycommand --option | ||
| + | ~~~ | ||
| + | |||
| + | set the affinity of a running process | ||
| + | ~~~bash | ||
| + | taskset -c -pa 0 1234 | ||
| + | ~~~ | ||
| + | |||
| + | |||
