|
| 1 | +package benchmark; |
| 2 | + |
| 3 | +import io.gatling.javaapi.core.*; |
| 4 | +import io.gatling.javaapi.http.*; |
| 5 | + |
| 6 | +import static io.gatling.javaapi.core.CoreDsl.*; |
| 7 | +import static io.gatling.javaapi.http.HttpDsl.*; |
| 8 | + |
| 9 | +import java.time.Duration; |
| 10 | + |
| 11 | +/** |
| 12 | + * Heavy Load Simulation for JIT Profiling |
| 13 | + * - Warm-up: ~20,000 requests |
| 14 | + * - Load test: ~80,000 requests |
| 15 | + * - Total: ~100,000 requests |
| 16 | + */ |
| 17 | +public class HeavyLoadSimulation extends Simulation { |
| 18 | + |
| 19 | + HttpProtocolBuilder httpProtocol = http |
| 20 | + .baseUrl("http://localhost:8080") |
| 21 | + .acceptHeader("text/plain,application/json") |
| 22 | + .userAgentHeader("Gatling Heavy Load Test") |
| 23 | + .shareConnections() // 커넥션 재사용 |
| 24 | + .disableFollowRedirect() |
| 25 | + .disableWarmUp() // Gatling 기본 warm-up 비활성화 |
| 26 | + .maxConnectionsPerHost(500) |
| 27 | + .connectionHeader("keep-alive") |
| 28 | + .header("Keep-Alive", "timeout=5, max=1000"); |
| 29 | + |
| 30 | + // Warm-up 시나리오: 약 20,000 요청 |
| 31 | + // 목적: 서버 JVM JIT 컴파일, 스레드풀, 커넥션 풀 예열 |
| 32 | + ScenarioBuilder warmUp = scenario("Warm-up Phase") |
| 33 | + .exec( |
| 34 | + http("Warm-up request") |
| 35 | + .get("/benchmark/hello") |
| 36 | + .check(status().is(200)) |
| 37 | + ); |
| 38 | + |
| 39 | + // Heavy Load 시나리오: 약 80,000 요청 |
| 40 | + // 목적: JIT 컴파일 완료 후 steady-state 성능 측정 |
| 41 | + ScenarioBuilder heavyLoad = scenario("Heavy Load Test") |
| 42 | + .exec( |
| 43 | + http("GET /benchmark/hello") |
| 44 | + .get("/benchmark/hello") |
| 45 | + .check(status().is(200)) |
| 46 | + ); |
| 47 | + |
| 48 | + { |
| 49 | + setUp( |
| 50 | + // ======================================== |
| 51 | + // Phase 1: Warm-up (~20,000 requests) |
| 52 | + // ======================================== |
| 53 | + warmUp.injectOpen( |
| 54 | + // 점진적 증가: 0 -> 100 RPS (5초) |
| 55 | + rampUsersPerSec(0).to(100).during(Duration.ofSeconds(5)), |
| 56 | + // 안정적 부하: 100 RPS (10초) = 1,000 requests |
| 57 | + constantUsersPerSec(100).during(Duration.ofSeconds(10)), |
| 58 | + // 중간 부하: 300 RPS (20초) = 6,000 requests |
| 59 | + constantUsersPerSec(300).during(Duration.ofSeconds(20)), |
| 60 | + // 고부하: 500 RPS (25초) = 12,500 requests |
| 61 | + constantUsersPerSec(500).during(Duration.ofSeconds(25)) |
| 62 | + // Total: ~19,500 requests |
| 63 | + ).protocols(httpProtocol), |
| 64 | + |
| 65 | + // ======================================== |
| 66 | + // Phase 2: Heavy Load (~80,000 requests) |
| 67 | + // ======================================== |
| 68 | + heavyLoad.injectOpen( |
| 69 | + // warm-up 완료 대기 |
| 70 | + nothingFor(Duration.ofSeconds(60)), |
| 71 | + |
| 72 | + // 점진적 램프업: 100 -> 1000 RPS (10초) |
| 73 | + rampUsersPerSec(100).to(1000).during(Duration.ofSeconds(10)), |
| 74 | + |
| 75 | + // 고부하 구간 1: 1000 RPS (30초) = 30,000 requests |
| 76 | + constantUsersPerSec(1000).during(Duration.ofSeconds(30)), |
| 77 | + |
| 78 | + // 최대 부하: 1000 -> 1500 RPS (10초) |
| 79 | + rampUsersPerSec(1000).to(1500).during(Duration.ofSeconds(10)), |
| 80 | + |
| 81 | + // 고부하 구간 2: 1500 RPS (30초) = 45,000 requests |
| 82 | + constantUsersPerSec(1500).during(Duration.ofSeconds(30)), |
| 83 | + |
| 84 | + // 점진적 감소: 1500 -> 500 RPS (10초) |
| 85 | + rampUsersPerSec(1500).to(500).during(Duration.ofSeconds(10)) |
| 86 | + // Total: ~80,000 requests |
| 87 | + ).protocols(httpProtocol) |
| 88 | + ) |
| 89 | + .assertions( |
| 90 | + // 최대 응답시간 1초 이하 |
| 91 | + global().responseTime().max().lt(1000), |
| 92 | + // 95 percentile 응답시간 500ms 이하 |
| 93 | + global().responseTime().percentile3().lt(500), |
| 94 | + // 성공률 99% 이상 |
| 95 | + global().successfulRequests().percent().gt(99.0), |
| 96 | + // 초당 요청 처리량 (throughput) 체크 |
| 97 | + global().requestsPerSec().gt(500.0) |
| 98 | + ); |
| 99 | + } |
| 100 | +} |
0 commit comments