๐ป ์์คํ ์ค์น ๋ฐ ์คํ ์๊ตฌ์ฌ์ (System Requirements)
์ต์ Gatling TypeScript/JavaScript SDK (@gatling.io/core, @gatling.io/http) ๋ฐ JVM Engine ๊ธฐ์ค ์๊ตฌ์ฌ์์
๋๋ค.
| ๊ตฌ๋ถ | ์ต์ ์ฌ์ (Minimum) | ๊ถ์ฅ ์ฌ์ (Recommended) |
|---|---|---|
| ์ด์์ฒด์ (OS) | Linux, macOS, Windows | Ubuntu 24.04 LTS (ulimit -n 65535 ํ์ผ ๋์คํฌ๋ฆฝํฐ ๊ถ์ฅ) |
| Java ๋ฐํ์ (ํ์) | OpenJDK 11 ~ 25 (LTS) | OpenJDK 21 ๋๋ 25 LTS (TypeScript SDK๋ ๋ด๋ถ ์์ง ์คํ์ JDK ํ์) |
| Node.js (TS/JS ์ฌ์ฉ ์) | Node.js 20+ / npm 10+ | Node.js 24 LTS / npm 11+ (@gatling.io/core, @gatling.io/http) |
| CPU / RAM | 2 vCPU / 2 GB RAM | 4 ~ 8+ vCPU / 4 GB ~ 16 GB RAM (Netty ๋น๋๊ธฐ I/O ๊ธฐ๋ฐ ๊ณ ๋์์ฑ ์ฒ๋ฆฌ) |
์ต์ ๋ฒ์ ์ค์น (TypeScript ํ๋ก์ ํธ ๊ธฐ์ค)
# 1. Java 21+ ํ์ธ (Gatling ์์ง ์คํ ํ์)
java -version
# 2. TypeScript Gatling ํ๋ก์ ํธ ์ด๊ธฐํ ๋๋ ๊ณต์ ํ
ํ๋ฆฟ ํด๋ก
mkdir gatling-perf && cd gatling-perf
npm init -y
npm install --save-dev @gatling.io/core @gatling.io/http @gatling.io/cli typescript
๐ง Gatling ๋ฉํ ๋ชจ๋ธ (Protocol ยท Scenario ยท Injection Profile ยท Assertions)
Gatling์ ์ค๋ ๋๋ฅผ ๊ฐ์ ์ฌ์ฉ์๋ง๋ค 1๊ฐ์ฉ ์ ์ ํ์ง ์๊ณ Netty/Akka ๋น๋๊ธฐ ์ด๋ฒคํธ ๋ฃจํ ์์์ ์๋ง ๋ช ์ ๊ฐ์ ์ฌ์ฉ์(Virtual Users)๋ฅผ ๊ฐ๋ณ๊ฒ ์๋ฎฌ๋ ์ด์ ํฉ๋๋ค.
[httpProtocol] (BaseURL, ๊ณตํต ํค๋, ์ปค๋ฅ์
ํ)
โ
โผ
[Scenario (์ฌ์ฉ์ ์ฌ์ )] โโโถ exec(GET /api) โโโถ check(status=200, jsonPath) โโโถ pause(1s)
โ
โผ
[Injection Profile] (rampUsers / constantUsersPerSec / stressPeakUsers)
โ
โผ
[Assertions & HTML Report] (p95 < 300ms, failedRequests < 1% -> CI Exit Code)
๐ ๋จ๊ณ๋ณ ์ค์ ์ค์ต (Step-by-Step)
[1๋จ๊ณ] ํฌ๋ก์๋: TypeScript ์ฒซ ๋ถํ ์๋ฎฌ๋ ์ด์
(basic.gatling.ts)
@gatling.io/core์ @gatling.io/http๋ฅผ ์ฌ์ฉํด ํ์
์์ ํ HTTP ์๋๋ฆฌ์ค๋ฅผ ์์ฑํ๊ณ ์คํํฉ๋๋ค.
// src/basic.gatling.ts
import { simulation, scenario, rampUsers } from "@gatling.io/core";
import { http, status } from "@gatling.io/http";
export default simulation((setUp) => {
// 1. ๊ณตํต HTTP ํ๋กํ ์ฝ ์ค์
const httpProtocol = http
.baseUrl("https://httpbin.org")
.acceptHeader("application/json")
.userAgentHeader("Gatling-TS-Perf/1.0");
// 2. ์ฌ์ฉ์ ์๋๋ฆฌ์ค ์ ์
const scn = scenario("HealthAndGetScenario")
.exec(
http("GET_JSON_Sample")
.get("/json")
.check(status().is(200))
)
.pause(1);
// 3. 10์ด ๋์ 20๋ช
์ ๊ฐ์ ์ฌ์ฉ์๋ฅผ ์ ์ง ํฌ์
(Ramp-up)
setUp(
scn.injectOpen(rampUsers(20).during(10))
).protocols(httpProtocol);
});
# Gatling CLI๋ก ์๋ฎฌ๋ ์ด์
์คํ (์๋ฃ ํ target/gatling/.../index.html ๋ฆฌํฌํธ ์๋ ์์ฑ)
npx gatling run --simulation basic
[2๋จ๊ณ] ํต์ฌ ๊ธฐ๋ฅ: CSV Feeder ๋ฐ์ดํฐ ์ฃผ์ , JSON ์ถ์ถ ๋ฐ ์๊ด๊ด๊ณ(Correlation)
์ค๋ฌด์์๋ ๋ก๊ทธ์ธ ์๋ต์์ ํ ํฐ์ด๋ orderId๋ฅผ ์ถ์ถ(saveAs)ํด ๋ค์ ์์ฒญ์ ์ ๋ฌํ๊ณ , csv Feeder๋ก ๋งค ์ฌ์ฉ์๋ง๋ค ๋ค๋ฅธ ํ
์คํธ ๋ฐ์ดํฐ๋ฅผ ์ฃผ์
ํฉ๋๋ค.
import { simulation, scenario, csv, jsonPath, constantUsersPerSec } from "@gatling.io/core";
import { http, status, StringBody } from "@gatling.io/http";
export default simulation((setUp) => {
const httpProtocol = http.baseUrl("https://api.example.com");
// resources/users.csv (username,password ์ปฌ๋ผ) ์ํ ์ฝ๊ธฐ
const userFeeder = csv("users.csv").circular();
const orderFlow = scenario("AuthenticatedOrderFlow")
.feed(userFeeder)
.exec(
http("Login")
.post("/auth/login")
.header("Content-Type", "application/json")
.body(StringBody('{"username":"#{username}","password":"#{password}"}'))
.check(status().is(200))
.check(jsonPath("$.accessToken").saveAs("authToken"))
)
.pause(1, 3)
.exec(
http("CreateOrder")
.post("/v1/orders")
.header("Authorization", "Bearer #{authToken}")
.body(StringBody('{"sku":"PRO-PLAN","qty":1}'))
.check(status().in(200, 201))
);
// Open Workload Model: 30์ด๊ฐ ์ด๋น 15๋ช
์ ์ ๊ท ์ฌ์ฉ์ ์ ์
์ ์ง
setUp(
orderFlow.injectOpen(constantUsersPerSec(15).during(30))
).protocols(httpProtocol);
});
[3๋จ๊ณ] ์ค๋ฌด ์์ฉ: CI/CD์ฉ assertions SLO ๊ฒ์ดํธ & Open/Closed ๋ชจ๋ธ ์ ํ
์๋ฎฌ๋ ์ด์
์ข
๋ฃ ์ ์๋ต ์๊ฐ(p95/p99)๊ณผ ์ฑ๊ณต๋ฅ ๊ธฐ์ค์ assertions๋ก ๊ฑธ์ด๋๋ฉด, ๊ธฐ์ค ๋ฏธ๋ฌ ์ Gatling์ด 0์ด ์๋ ์ข
๋ฃ ์ฝ๋๋ฅผ ๋ฐํํด CI ํ์ดํ๋ผ์ธ์ ์๋ ์ฐจ๋จํฉ๋๋ค.
import { simulation, scenario, global, rampUsers } from "@gatling.io/core";
import { http, status } from "@gatling.io/http";
export default simulation((setUp) => {
const httpProtocol = http.baseUrl("http://localhost:8080");
const scn = scenario("ApiSloGate").exec(http("GetItems").get("/api/items").check(status().is(200)));
setUp(
scn.injectOpen(rampUsers(100).during(30))
)
.protocols(httpProtocol)
.assertions(
global().responseTime().percentile(95).lt(250), // p95 < 250ms
global().successfulRequests().percent().gt(99.5) // ์ฑ๊ณต๋ฅ > 99.5%
);
});
๐ ์ํฌ๋ก๋ ๋ชจ๋ธ & CLI ์นํธ์ํธ
| ๊ตฌ๋ถ | ๋ฉ์๋ / ๋ช ๋ น์ด | ์ฉ๋ ๋ฐ ํน์ง |
|---|---|---|
| Open Model | injectOpen(constantUsersPerSec(50).during(60)) | ์น์ฌ์ดํธ์ฒ๋ผ ์ธ๋ถ ์ฌ์ฉ์๊ฐ ๊ณ์ ๋ค์ด์ค๋ ํ์ค ํธ๋ํฝ(๋์ฐฉ๋ฅ ์ค์ฌ) |
| Closed Model | injectClosed(constantConcurrentUsers(100).during(60)) | ์ฝ์ผํฐ/๋๊ธฐ์ด์ฒ๋ผ ๋์ ์ ์์ ์๋ฅผ ๊ณ ์ ์ ์งํ ๋ ์ฌ์ฉ |
| HTML ๋ฆฌํฌํธ | npx gatling run --simulation <name> | ์คํ ์๋ฃ ํ index.html ๋์๋ณด๋ ๊ฒฝ๋ก ์๋ ์ถ๋ ฅ |
| Java/Kotlin Gradle | ./gradlew gatlingRun | JVM ๋ฐฑ์๋ ํ๊ณผ ๋์ผ ์ ์ฅ์์์ ์คํ ์ ํ์ค ๋ช ๋ น์ด |
โ ์ค๋ฌด ์ฃผ์์ฌํญ & ํ๋ก๋์ ์ฒดํฌ๋ฆฌ์คํธ
- Open vs Closed ๋ชจ๋ธ ๊ตฌ๋ถ: ์ผ๋ฐ ์น/API ๋ถํ ํ
์คํธ์๋ ๋ฐ๋์
injectOpen์ ์ฌ์ฉํ์ธ์.injectClosed๋ ์๋ฒ๊ฐ ๋๋ ค์ง์๋ก ์์ฒญ ์๋๋ ๊ฐ์ด ์ค์ด๋ค์ด Coordinated Omission(์ฑ๋ฅ ์ ํ ์ํ) ํ์์ด ๋ฐ์ํ ์ ์์ต๋๋ค. - Feeder ๋ฐ์ดํฐ ์ถฉ๋ถ์ฑ ํ๋ณด:
csv("users.csv").queue()๋ชจ๋์์ ๋ฐ์ดํฐ ํ ์๋ณด๋ค ๋ง์ ๊ฐ์ ์ฌ์ฉ์๋ฅผ ํฌ์ ํ๋ฉด ํ ์คํธ๊ฐ ์ฆ์ ์ค๋จ๋ฉ๋๋ค. ๋๋ ๋ถํ ์.circular()๋๋.random()์ ์ฌ์ฉํ์ธ์. - ์์ (Warm-up) ๊ตฌ๊ฐ ๋ถ๋ฆฌ: JVM ๊ธฐ๋ฐ ์๋ฒ๋ฅผ ํ ์คํธํ ๋๋ JIT ์ปดํ์ผ๊ณผ ์ปค๋ฅ์ ํ ์๋ฐ์ ์ ์ํด ๋ณธ ๋ถํ ์ ์ 15~30์ด๊ฐ์ ๋ฎ์ Ramp-up ๊ตฌ๊ฐ์ ๋ฐ๋์ ๋์ด์ผ ์ ํํ p99 ์งํ๋ฅผ ์ป์ ์ ์์ต๋๋ค.
์๊ฒฌ ๋ฐ ์ง๋ฌธ
0์์ง ๋ฑ๋ก๋ ์๊ฒฌ์ด ์์ต๋๋ค. ์ฒซ ๋ฒ์งธ ๋๊ธ์ ๋จ๊ฒจ๋ณด์ธ์!
๋๊ธ ์์
๋๊ธ ์ญ์