Тёмный

Limit CPU usage on Ubuntu with Systemd cgroups 

Nevyan Neykov
Подписаться 2,2 тыс.
Просмотров 11 тыс.
50% 1

With the help of SystemD we will create CGroups in order to schedule CPU resources for a specific process. Useful if you would like to practice resources scheduling using system tools under Ubuntu.
Article on the subject: nevyan.blogspot.com/2019/10/c...
Ubuntu server administration course: www.udemy.com/course/ubuntu-l...
----------------------------------------------------------------------------------------------------------------
👥 SUBSCRIBE! ► ru-vid.com_c... ◄
----------------------------------------------------------------------------------------------------------------

Опубликовано:

 

15 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 29   
@NevyanNeykov
@NevyanNeykov 3 года назад
Don't forget to subscribe for new content: ru-vid.com
@h1-hackermater
@h1-hackermater Год назад
Hello from Argentina! I am so thankful for your explain in the video, because: I use Arch Linux on my laptop for my studies as software developer, and it was very useful to evade that my machine freeze and I can't use it, unless press reboot button (that's the only option).
@NevyanNeykov
@NevyanNeykov Год назад
Great to hear!
@mikehigdon9220
@mikehigdon9220 3 года назад
Very nice. Helped me for sure.
@NevyanNeykov
@NevyanNeykov 3 года назад
Glad it helped!
@user-ew2bg5us7w
@user-ew2bg5us7w 11 месяцев назад
@nevyan Thanks for the video. I have a requirement to limit CPU and memory usage of a particular process using systemd and cgroup. Is there a separate video on this ? This limitation should apply to all users. Or is there a way to add my process name or id using the method shown in this video ?
@NevyanNeykov
@NevyanNeykov 11 месяцев назад
Nice task I would also like to update the videos some day, as such cases need experimentation.
@Dan-hh7ve
@Dan-hh7ve 3 года назад
thanks for sharing Nevyan, what about settings for ex. CPUQuota for 1000 user permanently ? so it keeps this limit after reboot
@NevyanNeykov
@NevyanNeykov 3 года назад
From my case it was keeping the settings set, on one system I even had to reset them by setting them to -1. Depends on the systemd version I guess, otherwise you set them before provisioning the machine. From the docs: systemctl set-property - the adjustments will be made permanent unless --runtime option is passed.
@mikehigdon9220
@mikehigdon9220 3 года назад
@@NevyanNeykov I believe the settings are permanent unless you use the --runtime option from set-property
@NevyanNeykov
@NevyanNeykov 3 года назад
@@mikehigdon9220 exactly.
@MikkoRantalainen
@MikkoRantalainen 2 года назад
2:19 We can easily obtain our user id from /etc/passwd :D How about running "id -u" instead?
@NevyanNeykov
@NevyanNeykov 2 года назад
great tip :)
@hannaescalante4421
@hannaescalante4421 2 года назад
Hello. How do you limit memory usage for mongodb using cgroups?
@NevyanNeykov
@NevyanNeykov 2 года назад
probably the same way as any other application ?
@_VISION.
@_VISION. 2 года назад
What if you don't have a login user at the moment? I'm trying to do this in live boot mode before I download Linux again
@NevyanNeykov
@NevyanNeykov 2 года назад
hi, probably you can use system.slice.
@kamalraj2213
@kamalraj2213 Год назад
I have a question. I am having aks cluster. So how i can actually check whether cgroup has been there and how to check if there is limit and request for pod has been there in cgroup. Can someone help plz
@NevyanNeykov
@NevyanNeykov Год назад
if you are using Kubernetes you can check with: kubectl describe pod Name_of_pod for podman: sudo podman stats --no-stream Name_of_pod
@MikkoRantalainen
@MikkoRantalainen 2 года назад
Do you know how to *easily* configure systemd to put all Google Chrome processes in a single memory cgroup and limit the max memory usage to 50% of the system RAM on Ubuntu? It used to be easy with cgmanager but that can no longer be used with systemd because systemd wants to control everything.
@NevyanNeykov
@NevyanNeykov 2 года назад
perhaps those ones could be of help: unix.stackexchange.com/questions/451577/limit-memory-for-browser-on-fedora unix.stackexchange.com/questions/659744/why-cant-cpulimit-limit-chromium-browser
@MikkoRantalainen
@MikkoRantalainen 2 года назад
@@NevyanNeykov Other than the example with `systemd-run` require using cgmanager which is no longer supported with recent systemd versions. And the `systemd-run` only works if that's the only way you actually launch that process.
@NevyanNeykov
@NevyanNeykov 2 года назад
Another possibility is to wrap the chromium process into a service where to use: MemoryMax to set the memory limit. On boot SystemD will auto start the service and apply the set limits to each new chromium instance.
@MikkoRantalainen
@MikkoRantalainen 2 года назад
@@NevyanNeykov How would you do that? Chromium requires a separate X display connection for each logged in user. With cgmanager it was simple to create one memory cgroup for Chrome/Chromium but with systemd there doesn't seem to be any simple way to do that.
@NevyanNeykov
@NevyanNeykov 2 года назад
here is for firefox I guess: serverfault.com/questions/1058897/applying-systemd-control-group-resource-limits-automatically-to-specific-user-ap
@anupganvir4492
@anupganvir4492 Год назад
I changed CPUQuota=50% and my system became very slow now. Please advise how to revert these changes.
@NevyanNeykov
@NevyanNeykov Год назад
try to set them to -1 or 0.
@--_-_-_-_-_-_-_-_
@--_-_-_-_-_-_-_-_ Год назад
I can't find user.slice I have ubuntu 16.4
@NevyanNeykov
@NevyanNeykov Год назад
Please use more recent version of Ubuntu, probably the feature is not implemented in the cgroups.
Далее
Linux, Namespaces, Cgroups и Контейнеры
23:57
How to understand the linux control groups cgroups
20:34
Coca-Cola 😂🫲
00:20
Просмотров 3,6 млн
Linux Performance Troubleshooting Demos
10:51
Просмотров 58 тыс.
Understanding user namespaces - Michael Kerrisk
53:30
SSH Crash Course | With Some DevOps
55:02
Просмотров 545 тыс.