상황
트래픽이 급격히 증가했을 때 HTTP 요청 지연이 발생하였음.
- JVM 내 스레드 급격히 증가
- 스레드는 급격히 증가한 후 peak치 유지한 후 점진적으로 감소
- 동시점에 http duration 급증, 마찬가지로 급진적 감소

원인
- 일시적으로 평시의 2~4배에 달하는 요청이 인입됨.
- 스레드 생성으로 인한 CPU Usage 증가
- 요청 처리를 위한 스레드 생성 대기열로 인한 CPU load 증가
- 요청 대기로 인한 지연 발생
- 생성된 스레드는 Tomcat이 수거하기 전까지 수 시간 이상 Idle Thread pool 잔류
해결 방안
spring boot의 server.tomcat.threads.min-spare 값을 튜닝하여 스파이크 상황에서 스레드 생성으로 인한 대기 현상을 최소화 함.
- 참고
- max-thread는 로그가 기본적으로 스레드 수는 1K 이하로 떨어지지 않는것을 고려하여 2K로 설정
- 각 어플리케이션의 운영 환경에 따라 취사 조정 가능할 것으로 보임.
server.tomcat.threads.min-spare=2000
Apache Tomcat 9 Configuration Reference (9.0.93) - The Executor (thread pool)
The Executor represents a thread pool that can be shared between components in Tomcat. Historically there has been a thread pool per connector created but this allows you to share a thread pool, between (primarily) connector but also other components when
tomcat.apache.org
'트러블 슈팅 > Spring' 카테고리의 다른 글
상황
트래픽이 급격히 증가했을 때 HTTP 요청 지연이 발생하였음.
- JVM 내 스레드 급격히 증가
- 스레드는 급격히 증가한 후 peak치 유지한 후 점진적으로 감소
- 동시점에 http duration 급증, 마찬가지로 급진적 감소

원인
- 일시적으로 평시의 2~4배에 달하는 요청이 인입됨.
- 스레드 생성으로 인한 CPU Usage 증가
- 요청 처리를 위한 스레드 생성 대기열로 인한 CPU load 증가
- 요청 대기로 인한 지연 발생
- 생성된 스레드는 Tomcat이 수거하기 전까지 수 시간 이상 Idle Thread pool 잔류
해결 방안
spring boot의 server.tomcat.threads.min-spare 값을 튜닝하여 스파이크 상황에서 스레드 생성으로 인한 대기 현상을 최소화 함.
- 참고
- max-thread는 로그가 기본적으로 스레드 수는 1K 이하로 떨어지지 않는것을 고려하여 2K로 설정
- 각 어플리케이션의 운영 환경에 따라 취사 조정 가능할 것으로 보임.
server.tomcat.threads.min-spare=2000
Apache Tomcat 9 Configuration Reference (9.0.93) - The Executor (thread pool)
The Executor represents a thread pool that can be shared between components in Tomcat. Historically there has been a thread pool per connector created but this allows you to share a thread pool, between (primarily) connector but also other components when
tomcat.apache.org