zoukankan      html  css  js  c++  java
  • stress负载生成器使用简介

     

    一、Stress工具原始网页:

    https://people.seas.harvard.edu/~apw/stress/

    二、Docker镜像的构建过程(dockerfile):

    progrium/stress镜像的 Dockerfile内容 :

    FROM ubuntu:trusty

    MAINTAINER Jeff Lindsay <progrium@gmail.com>

    RUN apt-get update && apt-get install -y stress

    ENTRYPOINT ["/usr/bin/stress", "--verbose"]

    CMD []

    该镜像的Dockerfile文件说明Ubuntu 1404系统中自带stress小工具,该镜像较大,282MB。

    另一个stress镜像polinux/stress,它使用alpine作为基础镜像,从源码进行编译,整个镜像大小7.5MB,Dockerfile文件如下:

    FROM alpine:3.5

    # Stress Version can be found on offcial website of stress

    # https://people.seas.harvard.edu/~apw/stress/

    ENV STRESS_VERSION=1.0.4

        SHELL=/bin/bash

    RUN

      apk add --update bash g++ make curl &&

      curl -o /tmp/stress-${STRESS_VERSION}.tgz https://people.seas.harvard.edu/~apw/stress/stress-${STRESS_VERSION}.tar.gz &&

      cd /tmp && tar xvf stress-${STRESS_VERSION}.tgz && rm /tmp/stress-${STRESS_VERSION}.tgz &&

      cd /tmp/stress-${STRESS_VERSION} &&

      ./configure && make && make install &&

      apk del g++ make curl &&

      rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*

    CMD ['/usr/local/bin/stress']

    三、命令参考:

    $ docker run --rm -it polinux/stress stress --help

     

    四、Stress容器使用示例:

    $docker run --rm -it progrium/stress --cpu 2 --io 1 --vm 2 --vm-bytes 128M --timeout 60s

    或者:

    $ docker run --rm -it polinux/stress stress --cpu 2 --io 1 --vm 2 --vm-bytes 128M --timeout 60s --verbose

      --cpu 和--io 和--vm 后面的数值,分别是创建CPU、磁盘读写和内存的线程数,可根据需要单独使用,或者组合使用。

        运行3个容器,指定容器的--cpu-share的值分别为512、512、1024,这3个容器使用CPU的时间比例为1:1:2,使用ctop或者top查看CPU利用率,理想的情况下,CPU占用接近25%、25%、50%:

    docker run -itd --rm --cpu-share 512 progrium/stress --cpu 1  --timeout 100s

    docker run -itd --rm --cpu-share 512 progrium/stress --cpu 1  --timeout 100s

    docker run -itd --rm --cpu-share 1024 progrium/stress --cpu 1  --timeout 100s

     

       运行2个stress容器,测试内存的占用,每个容器产生4个线程,第一个容器每个线程消耗256MB内存,第二个容器的4个线程每个消耗128MB内存:

    docker run -itd --rm  progrium/stress --vm 4 --vm-bytes 256M  --timeout 100s

    docker run -itd --rm  progrium/stress --vm 4 --vm-bytes 128M  --timeout 100s

     

    参考链接:

    https://people.seas.harvard.edu/~apw/stress/

    https://people.seas.harvard.edu/~apw/stress/README 

    https://hub.docker.com/r/polinux/stress/builds/

    https://hub.docker.com/r/progrium/stress/

    Docker下使用stress进行压力测试

    http://blog.51cto.com/molewan/1757918

    docker高级应用之cpu与内存资源限制

    https://blog.csdn.net/pdw2009/article/details/78137759

    配置docker限制容器对cpu 内存和IO的资源使用

    https://www.centos.bz/2017/08/docker-limit-container-cpu-memory-io/

    Docker 运行时资源限制-内存memory、交换机分区Swap、CPU

    https://blog.csdn.net/candcplusplus/article/details/53728507

    Linux资源控制-CPU和内存

    https://www.cnblogs.com/wang_yb/p/3942208.html

  • 相关阅读:
    在mac守护进程中启动一个新进程
    OBS源码解析(3)OBSApp类介绍
    缩略图预览mini库
    Web Sql database 本地数据库
    React入口详解
    网页全屏显示
    使用cheerio爬数据兼容gbk和utf8
    前端自动化grunt的使用
    Emmet 神一样的sublime text插件
    BFC(Block Formatting Context)理解
  • 原文地址:https://www.cnblogs.com/rancher-maomao/p/10101139.html
Copyright © 2011-2022 走看看