[2] 기존 스레드 vs 가상 스레드 성능 비교 #2
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
가상 스레드 성능 테스트 결과
테스트 설정
테스트 시나리오
스레드 풀 설정
테스트 요약
일반 플랫폼 스레드 (Platform Threads)
가상 스레드 (Virtual Threads) ⚡
성능 개선율
상세 분석
1. 처리량 (Throughput) 비교
관찰 사항
플랫폼 스레드: 479.1 req/sec
가상 스레드: 3,921.6 req/sec
분석
2. 응답 시간 (Response Time) 비교
평균 응답 시간
플랫폼 스레드: 977 ms
가상 스레드: 105 ms
개선율: 9.3배 빠름
최대 응답 시간 (최악 케이스)
플랫폼 스레드: 1,141 ms
가상 스레드: 177 ms
개선율: 6.4배 빠름
응답 시간 안정성 (표준 편차)
플랫폼 스레드: 196.97
가상 스레드: 9.84
관찰 사항
3. 에러율 비교
플랫폼 스레드
가상 스레드
분석
4. 리소스 효율성
스레드 사용량
플랫폼 스레드: 50개 OS 스레드
가상 스레드:
메모리 효율성
분석
결론
가상 스레드의 장점 (실제 측정 결과)
성능:
리소스 효율:
안정성:
플랫폼 스레드의 한계 (실제 측정 결과)
종합 결론
Java 21의 가상 스레드는 I/O Bound 작업에서 성능 향상을 제공합니다.
spring.threads.virtual.enabled=true)권장 사항
가상 스레드 적용 추천 케이스:
주의사항:
synchronized블록 내에서 blocking I/O 피하기추가 실험 아이디어
실제 DB 쿼리 테스트
synchronized 블록 테스트