Skip to content

๐Ÿง‘๐Ÿปโ€๐Ÿ”ฌ Test cpu bound application performance.(๐Ÿ’ฅ Stress test) Performs 100,000 hash operations using the md5 algorithm.

Notifications You must be signed in to change notification settings

hyojaekim/cpu-bound-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CPU Bound Application

I/O Burst vs CPU Burst, I/O Bound vs CPU Bound

  • I/O Burst : I/O๋ฅผ ํ•˜๋Š” ์‹œ๊ฐ„์„ ์˜๋ฏธํ•˜๋ฉฐ, I/O Burst๊ฐ€ ๋งŽ์€ ๊ฒƒ์„ I/O Bound Application
  • CPU Burst : CPU๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์‹œ๊ฐ„์„ ์˜๋ฏธํ•˜๋ฉฐ, CPU Burst๊ฐ€ ๋งŽ์€ ๊ฒƒ์„ CPU Bound Application

Artillery๋กœ ์„ฑ๋Šฅ ์ธก์ •ํ•˜๊ธฐ

์‹œ์ž‘ํ•˜๊ธฐ

npm install -g artillery #Artillery ์„ค์น˜ํ•˜๊ธฐ
artillery run --output report.json cpu-test.yaml #ํ…Œ์ŠคํŠธ ์‹คํ–‰ -> json ํŒŒ์ผ ์ƒ์„ฑ
artillery report ./report.json #json ํŒŒ์ผ -> html๋กœ ๋ณ€ํ™˜ํ•ด์„œ ์‹คํ–‰ํ•˜๊ธฐ

Artillery ์Šคํฌ๋ฆฝํŠธ

config:
  target: "http://34.64.213.244"
  phases:
    - duration: 60
      arrivalRate: 2
      name: Warm up
scenarios:
  # We define one scenario:
  - name: "Just get hash"
    flow:
      # Get the details of the product:
      - get:
          url: "/hash/123"

Scale-up ํ›„, ์„ฑ๋Šฅ ํ…Œ์ŠคํŠธ

Scale up ํ›„, ํ…Œ์ŠคํŠธ

  • e2-micro(vCPU 2๊ฐœ, 1GB ๋ฉ”๋ชจ๋ฆฌ) -> e2-highmem-8(vCPU 8๊ฐœ, 64GB ๋ฉ”๋ชจ๋ฆฌ)
  • duration:360, arrivalRate:2๋กœ ์„ค์ • ํ›„, ์•ˆ์ •์ ์œผ๋กœ ํŠธ๋ž˜ํ”ฝ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
  • ํŠ€๋Š” ๊ตฌ๊ฐ„์ด ์žˆ๋Š”๋ฐ ์ด๋Š” VM์„ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์–ด์ฉ” ์ˆ˜ ์—†๋Š” ๊ฒƒ ๊ฐ™๋‹ค. PM๊ณผ ๋‹ฌ๋ฆฌ VM์€ ์ธ์ ‘ํ•œ ์ธ์Šคํ„ด์Šค์™€ ์ž์›์„ ๊ณต์œ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋Ÿฐ ํ˜„์ƒ์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.

์„ฑ๋Šฅ ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐ์ค€ ๋งŒ๋“ค๊ธฐ

  • ๋‚ด๊ฐ€ ์˜ˆ์ƒํ•˜๋Š” TPS๋ณด๋‹ค ์—ฌ์œ ๋กญ๊ฒŒ ์„ค์ •
  • ๊ธฐ๋Œ€ Latency๋ฅผ ๋งŒ์กฑํ•  ๋•Œ๊นŒ์ง€ ์„ฑ๋Šฅ ํ…Œ์ŠคํŠธํ•˜๊ธฐ
    • ๋‹จ์ผ ์š”์ฒญ ๋ ˆ์ดํ„ด์‹œ๊ฐ€ ๊ธฐ๋Œ€ ๋ ˆ์ดํ„ด์‹œ๋ณด๋‹ค ๋†’๋‹ค๋ฉด, Scale-out์œผ๋กœ ํ•ด๊ฒฐ๋˜์ง€ ์•Š๋Š”๋‹ค. ๋”ฐ๋ผ์„œ ์ฝ”๋“œ๊ฐ€ ๋น„ํšจ์œจ์ ์ด๋‚˜, I/O๊ฐ€ ๋ณ‘๋ชฉ์ด๊ฑฐ๋‚˜, ๋„คํŠธ์›Œํฌ์—์„œ ๋ ˆ์ดํ„ด์‹œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋‹ค์–‘ํ•œ ๋ถ€๋ถ„๋“ค์„ ๊ณ ๋ คํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•œ๋‹ค.
  • Scale-outํ•ด๋„ ์„ฑ๋Šฅ์ด ๋Š˜์ง€ ์•Š์œผ๋ฉด ๋ณ‘๋ชฉ์„ ์˜์‹ฌํ•˜์ž.
  • ์ฒ˜์Œ์—๋Š” ์งง์€ ์‹œ๊ฐ„์œผ๋กœ ์ ์€ TPS๋กœ ์‹œ์ž‘ -> TPS๋ฅผ ์กฐ๊ธˆ์”ฉ ์˜ฌ๋ ค์„œ ์–ธ์ œ๋ถ€ํ„ฐ ์งง์€ ์‹œ๊ฐ„์กฐ์ฐจ ๋ฒ„ํ‹ฐ์ง€ ๋ชปํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ
  • ์„œ๋น„์Šค Peak ์‹œ๊ฐ„์— ์œ ์ž…๋˜๋Š” ํŠธ๋ž˜ํ”ฝ์„ ๋ฒ„ํ‹ธ ์ˆ˜ ์žˆ๋Š” ์ˆ˜์ค€๊นŒ์ง€ ํ…Œ์ŠคํŠธ๊ฐ€ ํ•„์š”ํ•˜๋‹ค.
  • ์งง์€ ์‹œ๊ฐ„ ๋งค์šฐ ๋†’์€ ํŠธ๋ž˜ํ”ฝ์„ ๊ฒฌ๋”œ ์ˆ˜ ์žˆ๋Š” ์„œ๋ฒ„ ๊ฐœ์ˆ˜๋‚˜ ์ €์žฅ์†Œ, ์ฝ”๋“œ ๋ณ‘๋ชฉ์„ ์ฐพ์•˜๋‹ค๋ฉด ์ŠคํŠธ๋ ˆ์Šค ํ…Œ์ŠคํŠธ ์‹œ๊ฐ„์„ ์•„์ฃผ ๊ธธ๊ฒŒ ํ…Œ์ŠคํŠธํ•ด๋ณด์ž. (์žฅ๊ธฐ์ ์œผ๋กœ ์ž์›์ด ๊ณ ๊ฐˆ๋˜๋Š” ์ƒํƒœ์ผ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ)

๊ทธ๋ž˜ํ”„ ๊ฐ ์„ ์˜ ์˜๋ฏธ

  • [max] ๊ฐ€์žฅ ์˜ค๋ž˜ ๊ฑธ๋ฆฐ ์š”์ฒญ โ†’ ์‘๋‹ต์‹œ๊ฐ„
  • [p95] ์ „์ฒด HTTP ํŠธ๋žœ์žญ์…˜ ์ค‘ ๊ฐ€์žฅ ๋น ๋ฅธ๊ฒƒ๋ถ€ํ„ฐ 95%๊นŒ์ง€ (๋Œ€๋ถ€๋ถ„์˜ ํŠธ๋ž˜ํ”ฝ)
  • [p50] ์ „์ฒด HTTP ํŠธ๋žœ์žญ์…˜ ์ค‘ ๊ฐ€์žฅ ๋น ๋ฅธ๊ฒƒ๋ถ€ํ„ฐ 50%๊นŒ์ง€ (์ ˆ๋ฐ˜ ํŠธ๋ž˜ํ”ฝ)
  • [min] ๊ฐ€์žฅ ๋น ๋ฅด๊ฒŒ ์˜จ ์š”์ฒญ โ†’ ์‘๋‹ต์‹œ๊ฐ„

์‹ค์ œ ๋ฐด์น˜๋งˆํฌ๋ฅผ ์žด ๋•Œ ์–ด๋–ค ๊ฒƒ์„ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๋Š”๊ฐ€?

  • ์‹ค์ œ ๋ฒค์น˜๋งˆํฌ๋ฅผ ์žด ๋•Œ p99์™€ p95 ๋‘๊ฐ€์ง€ ๊ทธ๋ž˜ํ”„๋ฅผ ๋งŽ์ด ๊ทธ๋ฆฐ๋‹ค. p99๋Š” ๋Œ€๋ถ€๋ถ„ ํŠธ๋ž˜ํ”ฝ์ด ํ•ด๋‹น๋˜๊ธฐ ๋•Œ๋ฌธ์— ์‹ค์ œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„ฑ๋Šฅ์— ๊ฐ€๊น๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
  • max๋Š” ๋„คํŠธ์›Œํฌ๋Š” ์ƒ๋‹นํžˆ ๋ถˆ์•ˆ์ •ํ•œ ์กด์žฌ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ „์ฒด ์„ฑ๋Šฅ ์ธก์ • ๊ฒฐ๊ณผ์— ์˜ํ–ฅ์„ ๋ฏธ์น˜๋Š” ๊ฒƒ์ด ๋ฐ”๋žŒ์งํ•˜์ง€ ์•Š๋‹ค.

Docker ์ด๋ฏธ์ง€๋กœ ๋งŒ๋“ค์–ด ๋ฐฐํฌํ•˜๊ธฐ

docker

  1. dockerfile์„ ๋นŒ๋“œํ•˜๋ฉด docker ์ด๋ฏธ์ง€๊ฐ€ ๋œ๋‹ค. (๋กœ์ปฌ ํ™˜๊ฒฝ)
    • Build ๋ช…๋ น์–ด docker build -t ์‚ฌ์šฉ์ž์ด๋ฆ„/์ €์žฅ์†Œ์ด๋ฆ„ .
  2. ์ด๋ฏธ์ง€๋ฅผ ์ €์žฅ์†Œ(dockerhub)์— pushํ•˜๋ฉด ํ•ด๋‹น ์ €์žฅ์†Œ์— ์—…๋กœ๋“œ ๋œ๋‹ค.
    • Push ๋ช…๋ น์–ด docker push ์‚ฌ์šฉ์ž์ด๋ฆ„/์ €์žฅ์†Œ์ด๋ฆ„
  3. ์ €์žฅ์†Œ์— ์žˆ๋Š” ์ด๋ฏธ์ง€๋ฅผ pullํ•˜๋ฉด ์ด๋ฏธ์ง€๊ฐ€ ๋‹ค์šด๋กœ๋“œ ๋œ๋‹ค. (GCP Instance)
    • Pull ๋ช…๋ น์–ด docker pull ์‚ฌ์šฉ์ž์ด๋ฆ„/์ €์žฅ์†Œ์ด๋ฆ„
  4. ๋‹ค์šด๋กœ๋“œ ๋œ ์ด๋ฏธ์ง€๋ฅผ runํ•˜๋ฉด container๊ฐ€ ๋˜์–ด์„œ ๋น„๋กœ์†Œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์‹คํ–‰๋œ๋‹ค.
    • Run ๋ช…๋ น์–ด docker run -p {HOST_PORT}:{CONTAINER_PORT} ์‚ฌ์šฉ์ž์ด๋ฆ„/์ €์žฅ์†Œ์ด๋ฆ„

Jenkins๋ฅผ ํ†ตํ•ด Dockerized Application ๋ฐฐํฌ ์ž๋™ํ™”ํ•˜๊ธฐ

  • Jenkinks ์ธ์Šคํ„ด์Šค, Worker ์ธ์Šคํ„ด์Šค 2๊ฐœ ๋งŒ๋“ค๊ธฐ
  • Jenkins์—์„œ ๊ฐœ์ธํ‚ค์™€ ๊ณต๊ฐœํ‚ค๋ฅผ ์Œ์œผ๋กœ ๋งŒ๋“ค์–ด Worker ์ธ์Šคํ„ด์Šค ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ์— ๊ณต๊ฐœํ‚ค๋ฅผ ๋„ฃ์–ด์ค€๋‹ค.
    • ๋Œ€์นญํ‚ค: ์•”ํ˜ธํ™”์— ์‚ฌ์šฉํ•˜๋Š” ํ‚ค์™€ ๋ณตํ˜ธํ™”์— ์‚ฌ์šฉํ•˜๋Š” ํ‚ค๊ฐ€ ๊ฐ™์€ ๊ฒƒ.
    • ๋น„๋Œ€์นญํ‚ค: ์•”ํ˜ธํ™”์— ์‚ฌ์šฉํ•˜๋Š” ํ‚ค์™€ ๋ณตํ˜ธํ™”์— ์‚ฌ์šฉํ•˜๋Š” ํ‚ค๊ฐ€ ๋‹ค๋ฅธ ๊ฒƒ. (๋‹ค๋ฅธ ๊ฐ’์ด์ง€๋งŒ ์—ฐ๊ด€๋˜์–ด ์žˆ๋Š” ๊ฐ’์ด๋‹ค)
  • Publish over SSH ์ž‘์„ฑํ•˜๊ธฐ
  • ๋ฐฐํฌ ์Šคํฌ๋ฆฝํŠธ ์ž‘์„ฑ

์ ์šฉํ•˜๋ฉด์„œ ๋ฐœ์ƒํ–ˆ๋˜ ๋ฌธ์ œ๋“ค

  1. bash: docker: command not found - ๋„์ปค๊ฐ€ ์„ค์น˜๋˜์ง€ ์•Š์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜
    • sudo yum install docker
    • sudo systemctl start docker
  2. /var/run/docker.sock: connect: permission denied - docker.sock ๊ถŒํ•œ ๋ฌธ์ œ
    • sudo chmod 666 /var/run/docker.sock
  3. Jenkins์—์„œ ํ†ฐ์บฃ์ด ๋„์›Œ์กŒ์ง€๋งŒ, ๋นจ๊ฐ„์ƒ‰ ๊ทธ๋ž˜ํ”„๋‚˜ ์‹œ๊ณ„๊ฐ€ ๊ณ„์† ๋„๋Š” ํ˜„์ƒ - Jenkins์—์„œ ๋ฐฐํฌ๊ฐ€ ๋๋‚˜์ง€ ์•Š์•˜๋‹ค๊ณ  ์ธ์‹ํ•˜๋Š” ๋ฌธ์ œ
    • ๋ฐฑ๊ทธ๋ผ์šด๋“œ๋กœ ์‹คํ–‰์ด ํ•„์š” nohup docker run -p 80:8080 ์‚ฌ์šฉ์ž์ด๋ฆ„/์ €์žฅ์†Œ์ด๋ฆ„ > /dev/null 2>^&1 &

์ธ์Šคํ„ด์Šค๊ฐ€ n๊ฐœ์ผ ๋•Œ, ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅํ•œ TPS ๋น„๊ต

Docker container ์šฐ์•„ํ•˜๊ฒŒ(?) ์ข…๋ฃŒํ•˜๊ธฐ

  • graceful shutdown
  • docker ps | grep {์ด๋ฏธ์ง€ ์ด๋ฆ„} ํ˜„์žฌ ์‹คํ–‰์ค‘์ธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ํ™•์ธํ•˜๊ธฐ
  • docker container kill -s 15 {Container ID} -s 15 ์˜ต์…˜์œผ๋กœ ์šฐ์•„ํ•˜๊ฒŒ ์ข…๋ฃŒ(์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์‹คํ–‰์ค‘์ธ ์ผ์„ ๋ชจ๋‘ ์ฒ˜๋ฆฌํ•˜๊ณ  ์ข…๋ฃŒํ•œ๋‹ค.)

Case 1. ์ธ์Šคํ„ด์Šค๊ฐ€ 3๊ฐœ์ผ ๋•Œ

  1. 360s - instance:3, ArrivalRate:1 stress test 1
  2. 360s - instance:3, ArrivalRate:8 stress test 2
  3. 360s - instance:3, ArrivalRate:16 stress test 3

ArrivalRate(vuser) 1 ~ 8์€ ๋ชจ๋“  ์š”์ฒญ์— ๋Œ€ํ•ด ํŠ€๋Š” ๊ตฌ๊ฐ„์ด ๋ฐœ์ƒํ•˜์ง€๋งŒ, ์ •์ƒ์ ์œผ๋กœ ์‘๋‹ตํ•œ๋‹ค. ArrivalRate(vuser) 16๋ถ€ํ„ฐ 300ms ๊นŒ์ง€ ์ •์ƒ์ ์œผ๋กœ ์‘๋‹ตํ•˜๋‹ค๊ฐ€, 300ms ์ดํ›„๋กœ๋ถ€ํ„ฐ 500, 502 ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

Case 2. ์ธ์Šคํ„ด์Šค 3๊ฐœ์ผ ๋•Œ, 2๊ฐœ๋ฅผ ๋‚ด๋ ธ๋‹ค๊ฐ€ ๋‹ค์‹œ ์˜ฌ๋ ธ์„ ๋•Œ

  1. 1๋ฒˆ, 2๋ฒˆ, 3๋ฒˆ ์ธ์Šคํ„ด์Šค๊ฐ€ ์‚ด์•„์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ (๋ชจ๋“  ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์‚ด์•„์žˆ๋Š” ์ƒํƒœ์—์„œ ์ง„ํ–‰)
  2. ์ŠคํŠธ๋ ˆ์Šค ํ…Œ์ŠคํŠธ ์ง„ํ–‰ (360s - instance:3, ArrivalRate:2)
  3. 1๋ฒˆ, 2๋ฒˆ ์ธ์Šคํ„ด์Šค์—์„œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ข…๋ฃŒ์‹œํ‚ค๊ธฐ
  4. ์žฌ๋ฐฐํฌํ•˜๊ธฐ

stress test 4

์ค‘๊ฐ„์— ํŠ€๋Š” ๊ตฌ๊ฐ„์ด 2๊ฐœ์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์ข…๋ฃŒ์‹œ์ผฐ์„ ๋•Œ๋กœ ์˜ˆ์ƒ๋œ๋‹ค. ํ•˜์ง€๋งŒ ๋ชจ๋“  ์š”์ฒญ์„ 200์œผ๋กœ, ์ •์ƒ์ ์ธ ์‘๋‹ต์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. 2๊ฐœ์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ์ข…๋ฃŒ์‹œ์ผฐ์Œ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์—ˆ๋˜ ์ด์œ ๋Š” ์ •์ƒ์ ์œผ๋กœ ๋ฌด์ค‘๋‹จ ๋ฐฐํฌ๊ฐ€ ์ด๋ฃจ์–ด์กŒ์Œ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

About

๐Ÿง‘๐Ÿปโ€๐Ÿ”ฌ Test cpu bound application performance.(๐Ÿ’ฅ Stress test) Performs 100,000 hash operations using the md5 algorithm.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published