1
00:00:00,000 --> 00:00:11,040
In this video, I'll tell you about process priority and cgroups.

2
00:00:11,040 --> 00:00:14,520
Because earlier you have learned about the NICE command.

3
00:00:14,520 --> 00:00:16,320
Now how does that relate to cgroups?

4
00:00:16,320 --> 00:00:17,600
Well, easy.

5
00:00:17,600 --> 00:00:21,959
If no cgroups resource allocation has been used, all processes are equal.

6
00:00:21,959 --> 00:00:24,660
And that's shown by the priority parameter.

7
00:00:24,660 --> 00:00:29,639
And you can use the NICE and RE-NICE commands to change process priorities.

8
00:00:29,639 --> 00:00:35,439
When cgroups are used, NICE values apply to processes with the same relative CPU weight.

9
00:00:35,439 --> 00:00:38,180
And the best practice, forget about NICE values.

10
00:00:38,180 --> 00:00:43,380
If you use cgroups, you use cgroups to define resource usage in general.

11
00:00:43,380 --> 00:00:48,099
And the only use case for the NICE value is where an individual user who is starting a

12
00:00:48,099 --> 00:00:52,060
heavy job can lower the priority of that heavy job.

13
00:00:52,060 --> 00:00:56,580
Let me demonstrate what may be going wrong on a system that is using NICE together with

14
00:00:56,580 --> 00:00:58,220
cgroups.

15
00:00:58,220 --> 00:01:03,380
So I'm going to leave my top window up and running.

16
00:01:03,380 --> 00:01:08,220
And I'm going to start my stress services units again.

17
00:01:08,220 --> 00:01:11,459
These were explained in a previous lesson.

18
00:01:11,459 --> 00:01:17,820
So systemctl start on stress1 as well as stress2.

19
00:01:17,820 --> 00:01:21,000
And we see them popping up in top.

20
00:01:21,000 --> 00:01:26,300
Now I'm going to top where I'm using R. R is a top interface where you can RE-NICE,

21
00:01:26,300 --> 00:01:27,300
right?

22
00:01:27,379 --> 00:01:30,820
So I'm going to RE-NICE 4824.

23
00:01:30,820 --> 00:01:35,139
And I'm going to RE-NICE it to a value of 15.

24
00:01:35,139 --> 00:01:37,660
So I'm seriously trying to make it NICE.

25
00:01:37,660 --> 00:01:43,379
Now what you should observe is the percentage CPU usage, the priority, as well as the NICE

26
00:01:43,379 --> 00:01:44,379
value.

27
00:01:44,379 --> 00:01:46,660
And what do we see?

28
00:01:46,660 --> 00:01:50,459
We see that the CPU usage doesn't change a thing.

29
00:01:50,459 --> 00:01:54,620
Priority has changed and the NICE value has changed, but it just doesn't apply because

30
00:01:54,620 --> 00:01:57,019
cgroups apply as well.

31
00:01:57,019 --> 00:02:01,860
And that's what you need to keep in mind when you are using NICE on a system that has cgroups.

