Docker CPU资源限制?CPU分片功能测试
作者:网络转载 发布时间:[ 2016/2/22 14:07:45 ] 推荐标签:CPU 功能测试
之前的一篇随笔——Docker CPU 资源限制 中介绍了针对COU的某个或某几个核的控制,介绍下CPU分片功能,即COU占比。
测试步骤
1、下载CPU测试image。agileek/cpuset-test给出了一种用于测试CPU的image,功能是将CPU资源用满.
$ docker pull agileek/cpuset-test
2、观察未开任何应用时的CPU占用情况
[root@elk ~]# mpstat -P ALL 5 10
Linux 3.10.0-123.el7.x86_64 (elk) 02/16/2016 _x86_64_ (8 CPU)
08:10:57 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
08:11:02 AM all 0.05 0.00 0.13 0.00 0.00 0.00 0.00 0.00 0.00 99.82
08:11:02 AM 0 0.20 0.00 0.20 0.00 0.00 0.00 0.00 0.00 0.00 99.60
08:11:02 AM 1 0.00 0.00 0.20 0.00 0.00 0.00 0.00 0.00 0.00 99.80
08:11:02 AM 2 0.20 0.00 0.20 0.00 0.00 0.00 0.00 0.00 0.00 99.60
08:11:02 AM 3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
08:11:02 AM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
08:11:02 AM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
08:11:02 AM 6 0.00 0.00 0.20 0.00 0.00 0.00 0.00 0.00 0.00 99.80
08:11:02 AM 7 0.20 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.80
[root@elk ~]# top
top - 08:22:48 up 27 days, 20:31, 4 users, load average: 2.18, 7.36, 4.61
Tasks: 216 total, 1 running, 215 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.1 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 16151132 total, 3742548 used, 12408584 free, 6392 buffers
KiB Swap: 8200188 total, 0 used, 8200188 free. 1847800 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
11373 logstash 39 19 8087940 457188 15804 S 0.7 2.8 145:09.16 java
482 root 20 0 0 0 0 S 0.3 0.0 29:06.19 xfsaild/dm-1
31713 elastic+ 20 0 5797384 269444 14436 S 0.3 1.7 155:43.65 java
1 root 20 0 50684 4488 2336 S 0.0 0.0 0:32.37 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.45 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:04.83 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root rt 0 0 0 0 S 0.0 0.0 0:00.50 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/0
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/1
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/2
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/3
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/4
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/5
15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/6
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/7
17 root 20 0 0 0 0 S 0.0 0.0 16:09.47 rcu_sched
18 root 20 0 0 0 0 S 0.0 0.0 1:01.54 rcuos/0
19 root 20 0 0 0 0 S 0.0 0.0 0:53.77 rcuos/1
20 root 20 0 0 0 0 S 0.0 0.0 1:00.50 rcuos/2
21 root 20 0 0 0 0 S 0.0 0.0 0:53.75 rcuos/3
22 root 20 0 0 0 0 S 0.0 0.0 0:55.59 rcuos/4
23 root 20 0 0 0 0 S 0.0 0.0 0:44.15 rcuos/5
24 root 20 0 0 0 0 S 0.0 0.0 0:53.57 rcuos/6
3、开启一个容器,占CPU比重为1000,并观察CPU使用情况
[root@elk ~]# docker run -it --rm -c 1000 agileek/cpuset-test
Burning 8 CPUs/cores
另开终端观察CPU占用情况
[root@elk ~]# top
top - 08:14:33 up 27 days, 20:22, 4 users, load average: 7.26, 3.04, 1.18
Tasks: 220 total, 1 running, 219 sleeping, 0 stopped, 0 zombie
%Cpu(s):100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem: 16151132 total, 3745232 used, 12405900 free, 6508 buffers
KiB Swap: 8200188 total, 0 used, 8200188 free. 1849724 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
17258 root 20 0 36732 936 564 S 800.0 0.0 19:13.78 cpuburn
17218 root 20 0 0 0 0 S 0.3 0.0 0:00.02 kworker/0:2
17348 root 20 0 123680 1724 1148 R 0.3 0.0 0:00.01 top
1 root 20 0 50684 4488 2336 S 0.0 0.0 0:32.35 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.45 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:04.83 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root rt 0 0 0 0 S 0.0 0.0 0:00.50 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/0
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/1
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/2
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/3
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/4
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/5
15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/6
此时可以看到,PID17258的进程(也是我们刚刚开启的docker容器)CPU占到了全部8颗CPU的,也是800%。
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11