OS/Linux

부하 테스트를 위한 stress 툴

Temporary backups 2021. 3. 24. 00:06
반응형

 

stress는 부하 테스트를 위한 툴로써 다음과 같은 기능을 가지고 있습니다.

 

(1) rand()를 통한 임의의 숫자로 sqrt() 연산을 반복 수행하여 CPU 부하 테스트

(2) 메모리 버퍼를 디스크에 쓰는 sync() 시스템 콜을 통한 I/O 영역 테스트

(3) malloc(), free() 를 통한 메모리 부하 테스트

(4) mkstemp() 를 통한 디스크 부하 테스트

 

 

 

 

1. stress 패키지 다운로드

 

아래 링크를 통해 RHEL 또는 CentOS 버전에 맞는 rpm 파일을 wget을 통해 다운로드

http://pkgs.repoforge.org/stress/

 

 

2. stress 패키지 설치

yum install stress-1.0.2-1.el7.rf.x86_64.rpm

 

 

3. stress 명령어 옵션

       -v, --verbose
              be verbose

       -q, --quiet
              be quiet

       -n, --dry-run
              show what would have been done

       -t, --timeout N
              timeout after N seconds
           --backoff N
              wait factor of N microseconds before work starts

       -c, --cpu N
              spawn N workers spinning on sqrt()

       -i, --io N
              spawn N workers spinning on sync()

       -m, --vm N
              spawn N workers spinning on malloc()/free()

       --vm-bytes B
              malloc B bytes per vm worker (default is 256MB)

       --vm-stride B
              touch a byte every B bytes (default is 4096)

       --vm-hang N
              sleep N secs before free (default is none, 0 is inf)

       --vm-keep
              redirty memory instead of freeing and reallocating

       -d, --hdd N
              spawn N workers spinning on write()/unlink()

       --hdd-bytes B
              write B bytes per hdd worker (default is 1GB)

       --hdd-noclean
              do not unlink files created by hdd workers

 

 

4. 예제

 

1. 3G 크기의 파일을 디스크에 쓰고 지우는 작업을 1분간 연속으로 수행

stress --hdd 1 --hdd-bytes 3G -v --timeout 1m
또는
stress -d 1 --hdd-bytes 3G -v --timeout 1m

 

2. 3G 크기의 파일을 디스크에 쓰고 보관하는 작업을 1분간 연속으로 수행

stress --hdd 1 --hdd-noclean --hdd-bytes 3G -v --timeout 1m
또는
stress -d 1 --hdd-noclean --hdd-bytes 3G -v --timeout 1m

 

3. 8개의 프로세스로 CPU 부하 테스트, 4개의 프로세스로 I/O 영역 테스트, 2개의 프로세스로 메모리 테스트(128M씩 할당후 해제)를 10초간 수행

stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s -v
또는
stress -c 8 --io 4 -m 2 --vm-bytes 128M --timeout 10s -v 

 

반응형