🎯 Gatling · 레슨 6 / 6

Gatling CI/CD 연동 — GitHub Actions·Jenkins, 대규모 실행 전략

Maven 플러그인으로 CI에서 Gatling을 실행하고 어설션으로 성능 게이트를 만드는 방법, GitHub Actions와 Jenkins 예제, 실행 파일 패키징, 오픈소스 버전에서 여러 머신으로 부하를 늘리는 방법과 Gatling Enterprise, JavaScript SDK를 정리합니다.

⏱ 약 5분🗓 2026-11-11 업데이트🏷 Gatling 3.x 기준

이 레슨에서 배우는 것

  • CI에서 Gatling을 실행하고 리포트 보관하기
  • 어설션으로 PR·배포 게이트 만들기
  • 부하를 키워야 할 때의 선택지 이해하기

어설션이 곧 게이트

레슨 5의 assertions()가 실패하면 mvn gatling:test가 0이 아닌 종료 코드로 끝납니다. CI에서는 별도의 결과 파싱 없이 이 명령만 실행하면 됩니다. 단, CI에서 돌릴 시뮬레이션은 짧게(수 분) 만들고, 긴 스트레스·소크는 스케줄 실행으로 분리하세요.

SmokeGateSimulation.java (일부)java
{
  setUp(scn.injectOpen(constantUsersPerSec(Integer.getInteger("rate", 5))
          .during(Duration.ofSeconds(Long.getLong("durationSec", 120)))))
      .protocols(httpProtocol)
      .assertions(
          global().responseTime().percentile(95.0).lt(400),
          global().failedRequests().percent().lt(1.0)
      );
}

GitHub Actions

.github/workflows/gatling.ymlyaml
name: gatling-perf

on:
  pull_request:
    paths: ['src/**', 'perf/**']
  workflow_dispatch:

jobs:
  gatling:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    defaults:
      run:
        working-directory: perf
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: '21'
          cache: maven

      - name: Run Gatling
        run: |
          ./mvnw -B gatling:test \
            -Dgatling.simulationClass=perf.SmokeGateSimulation \
            -DbaseUrl=${{ vars.STAGING_URL }} -Drate=10 -DdurationSec=120

      - name: Upload report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: gatling-report
          path: perf/target/gatling/
✅

시뮬레이션이 여러 개인 프로젝트에서 gatling.simulationClass를 지정하지 않으면 실행이 대화형 선택을 기다리며 멈출 수 있습니다. CI에서는 항상 클래스를 지정하거나 -Dgatling.runMultipleSimulations=true로 전부 실행하세요.

Jenkins

Jenkins의 Gatling 플러그인은 빌드마다 리포트를 보관하고 추세 그래프를 보여 줍니다.

Jenkinsfilegroovy
pipeline {
  agent { label 'perf' }
  tools { jdk 'jdk21'; maven 'maven3' }
  stages {
    stage('Gatling') {
      steps {
        dir('perf') {
          sh './mvnw -B gatling:test -Dgatling.simulationClass=perf.LoadSimulation -DbaseUrl=https://staging.example.com'
        }
      }
    }
  }
  post {
    always {
      gatlingArchive()     // Gatling 플러그인: 리포트 보관 + 추세 그래프
    }
  }
}

실행 파일 패키징

부하 생성 머신마다 소스와 Maven을 두기 번거롭다면, 시뮬레이션과 의존성을 하나로 묶은 실행 가능한 JAR을 만들어 배포하는 방법이 있습니다. Gatling 데모 프로젝트에는 이를 위한 설정 예가 포함되어 있으며, Maven Shade·Assembly 플러그인으로도 만들 수 있습니다. 컨테이너 이미지로 만들어 두면 어느 환경에서든 같은 버전으로 실행할 수 있습니다.

부하를 더 키워야 할 때

Gatling 한 인스턴스는 적은 자원으로 많은 부하를 만들지만, 그래도 부족하다면 선택지는 다음과 같습니다.

방법특징
머신 사양 올리기가장 간단. 코어·네트워크 대역폭이 큰 머신 하나가 여러 대보다 관리가 쉽습니다
여러 머신에서 동시에 실행오픈소스 버전에는 분산 실행·결과 병합 기능이 없습니다. 각 머신에서 같은 시뮬레이션을 나눈 부하로 동시에 시작하고 결과는 각각 해석해야 합니다
Gatling Enterprise상용 버전. 여러 부하 생성기(클라우드·사내)를 조율하고 결과를 합쳐 실시간 대시보드와 회차 비교를 제공합니다
💡

여러 머신으로 직접 나눠 실행한다면 모든 머신의 시계를 NTP로 맞추고, 시작 시각을 맞추고, 머신별 도착률을 "전체 목표 ÷ 머신 수"로 설정하세요. 백분위수는 머신별 값을 단순 평균하면 안 됩니다.

JavaScript·TypeScript SDK

JVM 언어를 쓰지 않는 팀을 위해 Gatling은 JavaScript·TypeScript SDK도 제공합니다. DSL 구조(시나리오, 주입, 체크, 어설션)는 같고, npm 패키지와 CLI로 실행합니다(실행 시 Gatling 엔진이 자동으로 내려받아집니다).

src/basic.gatling.tstypescript
import { simulation, scenario, constantUsersPerSec } from "@gatling.io/core";
import { http, status } from "@gatling.io/http";

export default simulation((setUp) => {
  const httpProtocol = http.baseUrl("http://localhost:3333");

  const scn = scenario("메인").exec(
    http("GET /").get("/").check(status().is(200))
  );

  setUp(scn.injectOpen(constantUsersPerSec(5).during(60))).protocols(httpProtocol);
});
bash
npx gatling run --typescript --simulation basic   # 템플릿 프로젝트의 npm 스크립트를 따르세요

프로젝트 생성 방법과 지원 기능은 공식 문서의 JavaScript 시작 가이드를 확인하세요.

다음 단계

정리