In this video, I'll tell you about process priority and cgroups.
Because earlier you have learned about the NICE command.
Now how does that relate to cgroups?
Well, easy.
If no cgroups resource allocation has been used, all processes are equal.
And that's shown by the priority parameter.
And you can use the NICE and RE-NICE commands to change process priorities.
When cgroups are used, NICE values apply to processes with the same relative CPU weight.
And the best practice, forget about NICE values.
If you use cgroups, you use cgroups to define resource usage in general.
And the only use case for the NICE value is where an individual user who is starting a
heavy job can lower the priority of that heavy job.
Let me demonstrate what may be going wrong on a system that is using NICE together with
cgroups.
So I'm going to leave my top window up and running.
And I'm going to start my stress services units again.
These were explained in a previous lesson.
So systemctl start on stress1 as well as stress2.
And we see them popping up in top.
Now I'm going to top where I'm using R. R is a top interface where you can RE-NICE,
right?
So I'm going to RE-NICE 4824.
And I'm going to RE-NICE it to a value of 15.
So I'm seriously trying to make it NICE.
Now what you should observe is the percentage CPU usage, the priority, as well as the NICE
value.
And what do we see?
We see that the CPU usage doesn't change a thing.
Priority has changed and the NICE value has changed, but it just doesn't apply because
cgroups apply as well.
And that's what you need to keep in mind when you are using NICE on a system that has cgroups.