chore: 동시 접속 100명 기준 커넥션 풀/스레드 풀 설정 적용#141
Merged
Merged
Conversation
- HikariCP 풀 크기 15로 고정, 커넥션 획득 타임아웃 3초로 단축 - max-lifetime 29분 설정으로 MySQL wait_timeout 만료 커넥션 획득 방지 - Tomcat 스레드 최대 100, 대기 큐 100으로 조정 - 배포 시 처리 중 요청 유실 방지를 위한 graceful shutdown 적용 Co-Authored-By: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#️⃣연관된 이슈
📝작업 내용
동시 접속 100명 규모를 안정적으로 처리하도록 HikariCP 커넥션 풀과 Tomcat 스레드 풀 설정을 명시합니다. 기존에는 두 설정이 모두 없어 Spring Boot 기본값(Hikari
maximum-pool-size: 10, Tomcatthreads.max: 200)으로 동작하고 있었습니다.커넥션 풀 크기 산정
동시 접속 100명이 곧 커넥션 100개를 의미하지 않습니다. Little's law 기준 필요 커넥션 수는
처리량 × 요청당 DB 점유 시간입니다.여기에 느린 쿼리(납부자 목록 깊은 OFFSET 조회, 엑셀 생성)와
@Async알림 핸들러가 별도 스레드에서 점유하는 몫(기본 태스크 풀 8)을 더해 15로 잡았습니다. 이보다 크게 잡으면 DB 측 컨텍스트 스위칭과 락 경합이 늘어 오히려 처리량이 떨어집니다.수정 내용
hikari.maximum-pool-size@Async알림 처리 몫 반영hikari.minimum-idlehikari.connection-timeouthikari.max-lifetimewait_timeout으로 서버 측에서 먼저 끊긴 커넥션 획득 방지hikari.keepalive-timetomcat.threads.maxtomcat.threads.min-sparetomcat.accept-countserver.shutdown운영(
application-prod.yml)과 개발(application-dev.yml) 환경에 동일하게 적용했습니다. 개발 환경이 부하 테스트 대상이 되는 경우 설정이 어긋나면 측정값을 운영에 그대로 대입할 수 없기 때문입니다.Tomcat 스레드 수 > 커넥션 풀 크기 구조
threads.max: 100>maximum-pool-size: 15구성은 의도한 형태입니다. 커넥션을 얻지 못한 요청 스레드는 풀에서 대기하다 3초 내 실패하며, 요청 자체를 거절하는 것보다 낫습니다.💬리뷰 요구사항(선택)
max_connections확인이 필요합니다. 인스턴스를 여러 개로 띄우는 경우15 × 인스턴스 수가 DB 서버 한도 안에 들어와야 합니다. 기본값 151 기준으로는 2대까지 안전합니다.k6/run.sh 100 3m으로 실측해http_req_durationp95가 목표를 넘으면, 커넥션 풀보다 쿼리 자체(깊은 OFFSET 페이지네이션)를 먼저 확인하는 것이 맞다고 생각합니다. 풀 크기를 키워서는 해결되지 않는 종류의 문제입니다.server.tomcat.mbeanregistry.enabled: true와 actuator를 통해hikaricp.connections.pending,tomcat.threads.busy지표를 노출하는 방안도 있습니다. 별도 이슈로 분리하는 게 나을지 의견 부탁드립니다.