测试步骤 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的100%,也就是800%。 4、再开启一个容器,占CPU比重为3000,并观察CPU使用情况 [root@elk ~]# docker run -it --rm -c 3000 agileek/cpuset-test Burning 8 CPUs/cores 另开终端观察CPU占用情况 [root@elk ~]# top top - 08:17:35 up 27 days, 20:25, 4 users, load average: 11.86, 6.29, 2.72 Tasks: 227 total, 2 running, 225 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, 3752724 used, 12398408 free, 6624 buffers KiB Swap: 8200188 total, 0 used, 8200188 free. 1851692 cached Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 17494 root 20 0 36732 932 560 S 602.1 0.0 3:54.95 cpuburn 17258 root 20 0 36732 936 564 S 197.9 0.0 39:34.78 cpuburn 927 root 20 0 19112 1168 948 S 0.3 0.0 3:04.34 irqbalance 17532 root 20 0 123680 1732 1148 R 0.3 0.0 0:00.01 top 1 root 20 0 50684 4488 2336 S 0.0 0.0 0:32.36 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的1/4,也就是200%。而新开启的,占比3000的docker容器站到了全部8颗CPU的3/4,也就是600%。
(责任编辑:IT) |