first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
17
CloudNative/Docker/cgroup限制cpu
Normal file
17
CloudNative/Docker/cgroup限制cpu
Normal file
|
@ -0,0 +1,17 @@
|
|||
cgroup用来管理linux下的cpu资源,使用cgroup可以很好的限制程序的资源使用情况,下面是对cgroup限制程序cpu使用情况的一些介绍:
|
||||
|
||||
1、首先,构造一个占用cpu资源的程序
|
||||
|
||||
echo 'while True:pass'|python &
|
||||
|
||||
使用top命令可以看到该进程CPU使用达到90%以上
|
||||
|
||||
2、进入到/sys/fs/cgroup/cpu目录下,创建一个文件夹,例如test
|
||||
|
||||
3、进入到test文件夹下,会看到已自动创建了一些文件,此时,输入
|
||||
|
||||
echo 50000 > cpu.cfs_quota_us
|
||||
|
||||
echo 1741 > tasks
|
||||
|
||||
会使得把1741进程的cpu占用时间比例降到50%。使用top命令可以确认查看该设置是否成功。
|
Loading…
Add table
Add a link
Reference in a new issue