• docker 压力测试


    1、下载一个stress压力工具的镜像

    [root@docker ~]# docker pull joedval/stress
    Pulling repository joedval/stress
    7eb627cb08a2: Download complete 
    b0082ba983ef: Download complete 
    109b72e23ca5: Download complete 
    a1a076997d57: Download complete 
    Status: Downloaded newer image for joedval/stress:latest

    2、随机生成一个以“joedval/stress”镜像为基础的容器,设定权级为512

    [root@docker ~]# docker run -it --rm -c 512 joedval/stress --cpu 1
    stress: info: [1] dispatching hogs: 1 cpu, 0 io, 0 vm, 0 hdd
    可以看到cpu占用为99.6%,接近100%
    [root@docker ~]# top
    top - 15:19:07 up  1:04,  3 users,  load average: 1.62, 1.03, 0.43
    Tasks: 158 total,   2 running, 156 sleeping,   0 stopped,   0 zombie
    Cpu(s): 99.3%us,  0.3%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.3%hi,  0.0%si,  0.0%st
    Mem:   3910160k total,  1289624k used,  2620536k free,    96856k buffers
    Swap:  4194300k total,        0k used,  4194300k free,   914440k cached
       PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                              
      4144 root      20   0  7208  120   28 R 99.6  0.0   2:58.09 stress                                                                                
      4403 root      20   0 15032 1252  924 R  0.3  0.0   0:00.32 top                                                                                   
         1 root      20   0 19356 1532 1228 S  0.0  0.0   0:01.55 init                                                                                  
         2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd                                                                              
         3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                                           
         4 root      20   0     0    0    0 S  0.0  0.0   0:00.03 ksoftirqd/0                                                                           
         5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/0                                                                             
         6 root      RT   0     0    0    0 S  0.0  0.0   0:00.02 watchdog/0                                                                            
         7 root      20   0     0    0    0 S  0.0  0.0   0:01.62 events/0                                                                              
         8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events/0                                                                              
         9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events_long/0                                                                         
        10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events_power_ef                                                                       
        11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cgroup                                                                                
        12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper                                                                               
        13 root      20   0     0    0    0 S  0.0  0.0   0:00.03 netns                                                                                 
        14 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr                                                                             
        15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm                                                                                    
        16 root      20   0     0    0    0 S  0.0  0.0   0:00.02 sync_supers                                                                           
        17 root      20   0     0    0    0 S  0.0  0.0   0:00.01 bdi-default

    3、继续生成一个容器

    root@docker ~]# docker run -it --rm -c 512 joedval/stress --cpu 1
    stress: info: [1] dispatching hogs: 1 cpu, 0 io, 0 vm, 0 hdd
    [root@docker ~]# top
    top - 15:20:48 up  1:05,  3 users,  load average: 1.55, 1.13, 0.52
    Tasks: 164 total,   3 running, 161 sleeping,   0 stopped,   0 zombie
    Cpu(s): 99.0%us,  0.7%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.3%hi,  0.0%si,  0.0%st
    Mem:   3910160k total,  1298324k used,  2611836k free,    97924k buffers
    Swap:  4194300k total,        0k used,  4194300k free,   917480k cached
       PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                              
      4772 root      20   0  7208  124   28 R 49.9  0.0   0:16.12 stress                                                                                
      4144 root      20   0  7208  120   28 R 49.5  0.0   4:22.39 stress                                                                                
         1 root      20   0 19356 1532 1228 S  0.0  0.0   0:01.55 init                                                                                  
         2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd                                                                              
         3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                                           
         4 root      20   0     0    0    0 S  0.0  0.0   0:00.03 ksoftirqd/0                                                                           
         5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/0                                                                             
         6 root      RT   0     0    0    0 S  0.0  0.0   0:00.02 watchdog/0                                                                            
         7 root      20   0     0    0    0 S  0.0  0.0   0:01.66 events/0                                                                              
         8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events/0                                                                              
         9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events_long/0                                                                         
        10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events_power_ef                                                                       
        11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cgroup                                                                                
        12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper                                                                               
        13 root      20   0     0    0    0 S  0.0  0.0   0:00.03 netns                                                                                 
        14 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr                                                                             
        15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm                                                                                    
        16 root      20   0     0    0    0 S  0.0  0.0   0:00.02 sync_supers                                                                           
        17 root      20   0     0    0    0 S  0.0  0.0   0:00.01 bdi-default        
    然后,可以发现存在两个stress的进程,各占用49.5%
    我们再次添加一个容器,并修改下stress权限为1024
    [root@docker ~]# top
    top - 15:22:13 up  1:07,  4 users,  load average: 2.53, 1.50, 0.70
    Tasks: 171 total,   4 running, 167 sleeping,   0 stopped,   0 zombie
    Cpu(s): 99.3%us,  0.3%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.3%hi,  0.0%si,  0.0%st
    Mem:   3910160k total,  1318152k used,  2592008k free,    99008k buffers
    Swap:  4194300k total,        0k used,  4194300k free,   921024k cached
       PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                              
      4992 root      20   0  7208  120   28 R 49.5  0.0   0:09.79 stress                                                                                
      4144 root      20   0  7208  120   28 R 24.9  0.0   4:59.56 stress                                                                                
      4772 root      20   0  7208  124   28 R 24.6  0.0   0:53.28 stress                                                                                
         1 root      20   0 19356 1532 1228 S  0.0  0.0   0:01.55 init                                                                                  
         2 root      20   0     0    0    0 S  0.0  0.0   0:00.01 kthreadd                                                                              
         3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                                           
         4 root      20   0     0    0    0 S  0.0  0.0   0:00.03 ksoftirqd/0                                                                           
         5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/0                                                                             
         6 root      RT   0     0    0    0 S  0.0  0.0   0:00.02 watchdog/0                                                                            
         7 root      20   0     0    0    0 S  0.0  0.0   0:01.69 events/0                                                                              
         8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events/0                                                                              
         9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events_long/0                                                                         
        10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events_power_ef                                                                       
        11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cgroup                                                                                
        12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper                                                                               
        13 root      20   0     0    0    0 S  0.0  0.0   0:00.03 netns                                                                                 
        14 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr                                                                             
        15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm                                                                                    
        16 root      20   0     0    0    0 S  0.0  0.0   0:00.02 sync_supers

    4、查看容器信息:

    [root@docker ~]# docker ps -a
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
    fcc6cb7b064c        joedval/stress      "stress --cpu 1"    29 seconds ago      Up 28 seconds                                   drunk_rosalind      
    7c195fe2e038        joedval/stress      "stress --cpu 1"    2 minutes ago       Up 2 minutes                                    loving_galileo      
    9b19fbca489b        joedval/stress      "stress --cpu 1"    7 minutes ago       Up 7 minutes                                    furious_rosalind

    5、测试内存:

    [root@docker ~]# docker run -it --rm -m 128m joedval/stress --vm 1 --vm-bytes 120m --vm-hang 0
    stress: info: [1] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
    [root@docker ~]# docker ps -l
    CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
    9841ee711d7f        joedval/stress      "stress --vm 1 --vm-   8 seconds ago       Up 6 seconds                            boring_jones       
    [root@docker ~]# docker run -it --rm -m 128m joedval/stress --vm 1 --vm-bytes 512m --vm-hang 0
    stress: info: [1] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
    stress: FAIL: [1] (415) <-- worker 5 got signal 9
    stress: WARN: [1] (417) now reaping child worker processes
    stress: FAIL: [1] (421) kill error: No such process
    stress: FAIL: [1] (451) failed run completed in 3s
    [root@docker ~]# docker run -it --rm -m 128m joedval/stress --vm 1 --vm-bytes 255m --vm-hang 0
    stress: info: [1] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
    [root@docker ~]# docker run -it --rm -m 128m joedval/stress --vm 1 --vm-bytes 256m --vm-hang 0
    stress: info: [1] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
    stress: FAIL: [1] (415) <-- worker 6 got signal 9
    stress: WARN: [1] (417) now reaping child worker processes
    stress: FAIL: [1] (421) kill error: No such process
    stress: FAIL: [1] (451) failed run completed in 2s
    说明:不能超过预设值的两倍(比如上面案例中256m是128m,所以自动退出了)






    原文:http://www.bubuko.com/infodetail-1476963.html
  • 相关阅读:
    基于Adaboost的人脸检测算法
    操作系统笔试题及答案
    eclipse Maven plugin 配置
    网站服务管理系统系列教程之五
    2017第4周日
    2017春节~人生智慧箴言
    2017年初夕
    2017农历二十九
    王国维收藏真伪
    2017第3周二假期里该做的事
  • 原文地址:https://www.cnblogs.com/yangxiaochu/p/8520688.html
Copyright © 2020-2023  润新知