Skip to content

Commit 55eb4a7

Browse files
committed
test: 부하테스트 모니터링
1 parent 306cd51 commit 55eb4a7

18 files changed

+2993
-4
lines changed

ProjectVG.Api/ApiServiceCollectionExtensions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,14 @@ public static IServiceCollection AddDevelopmentCors(this IServiceCollection serv
7575

7676
return services;
7777
}
78+
79+
/// <summary>
80+
/// 부하테스트 전용 성능 모니터링 서비스
81+
/// </summary>
82+
public static IServiceCollection AddLoadTestPerformanceServices(this IServiceCollection services)
83+
{
84+
services.AddSingleton<PerformanceCounterService>();
85+
return services;
86+
}
7887
}
7988
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Microsoft.AspNetCore.Server.Kestrel.Core;
2+
3+
namespace ProjectVG.Api.Configuration;
4+
5+
/// <summary>
6+
/// 부하테스트 환경을 위한 성능 최적화 설정을 제공합니다.
7+
/// </summary>
8+
public static class LoadTestConfiguration
9+
{
10+
/// <summary>
11+
/// 부하테스트 환경에서 Kestrel 서버의 성능을 최적화합니다.
12+
/// </summary>
13+
/// <param name="options">Kestrel 서버 옵션</param>
14+
public static void ConfigureKestrelForLoadTest(KestrelServerOptions options)
15+
{
16+
// 연결 한도 설정 (부하테스트용 고성능)
17+
options.Limits.MaxConcurrentConnections = 1000;
18+
options.Limits.MaxConcurrentUpgradedConnections = 1000;
19+
20+
// 요청 크기 및 타임아웃 최적화
21+
options.Limits.MaxRequestBodySize = 10_000_000; // 10MB
22+
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(30);
23+
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
24+
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(10);
25+
26+
// HTTP/2 최적화
27+
options.Limits.Http2.MaxStreamsPerConnection = 100;
28+
options.Limits.Http2.HeaderTableSize = 4096;
29+
options.Limits.Http2.MaxFrameSize = 16384;
30+
31+
// 성능 로깅
32+
Console.WriteLine($"LoadTest Kestrel Configuration Applied:");
33+
Console.WriteLine($"- MaxConcurrentConnections: {options.Limits.MaxConcurrentConnections}");
34+
Console.WriteLine($"- MaxRequestBodySize: {options.Limits.MaxRequestBodySize} bytes");
35+
}
36+
37+
/// <summary>
38+
/// 부하테스트 환경에서 ThreadPool을 최적화합니다.
39+
/// </summary>
40+
public static void ConfigureThreadPoolForLoadTest()
41+
{
42+
// ThreadPool 최소 스레드 수 설정 (부하테스트용)
43+
ThreadPool.SetMinThreads(100, 100);
44+
45+
// ThreadPool 상태 로깅
46+
ThreadPool.GetMinThreads(out int minWorkerThreads, out int minCompletionPortThreads);
47+
ThreadPool.GetMaxThreads(out int maxWorkerThreads, out int maxCompletionPortThreads);
48+
49+
Console.WriteLine($"ThreadPool Configuration:");
50+
Console.WriteLine($"- Min Worker Threads: {minWorkerThreads}");
51+
Console.WriteLine($"- Min Completion Port Threads: {minCompletionPortThreads}");
52+
Console.WriteLine($"- Max Worker Threads: {maxWorkerThreads}");
53+
Console.WriteLine($"- Max Completion Port Threads: {maxCompletionPortThreads}");
54+
}
55+
}

0 commit comments

Comments
 (0)