Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE-INFRA] Tomcat thread pool 및 MongoDB connection pool 설정 #420

Open
wants to merge 4 commits into
base: be/develop
Choose a base branch
from

Conversation

unifolio0
Copy link

@unifolio0 unifolio0 commented Oct 24, 2024

🍄 PR 확인 사항

PR이 다음 요구 사항을 충족하는지 확인하세요. :

  • API 명세서가 업데이트 혹은 작성이 되어 있나요?

현재 작업은 어떤 이슈를 해결한 것인지 설명해주세요.

Issue Number: #419

  • 목표 TPS 설정
  • k6를 통한 부하 테스트
  • Tomcat thread pool과 MongoDB connection pool을 설정

기존 코드에서 변경된 점이 있다면 설명해주세요. (추가 X)

yml 파일 수정, 단일 포켓몬 정보 오류 수정, MongoConfig 수정


목표 TPS, VUser 설정 및 부하 테스트 진행 방식

  • 포켓로그 전세계 실시간 사용자 수: 약 6000명
  • 1%를 웃도는 100명으로 VUser 및 TPS 설정
  • k6로 100 VUser로 1분 간 부하 테스트
  • 모든 데이터는 평균값으로 통계
  • 서비스 핵심 기능 API로 테스트

Tomcat thread pool

포켓몬 전체 목록 조회 API

스크린샷 2024-10-24 오후 3 22 59

배틀 결과 계산 API

스크린샷 2024-10-24 오후 3 23 57

결론

  • max thread 값은 10으로 설정한다. 5도 높은 TPS 값을 가지지만 CPU 사용율 측면에서 10이 유리하다.

DB connection pool

  • 포켓몬 목록 조회 API는 캐싱을 사용하기 때문에 배틀 API로만 성능을 측정한다.
  • maxSize는 가장 TPS가 높은 10으로 설정한다.
  • minSize와 maxSize를 동일하게 설정해서 connection pool 이점을 최대한 활용한다.
  • waitingTime은 WAS 대기 시간보다 작은 값(2초)으로 설정한다. (default: 2분)
스크린샷 2024-10-24 오후 3 28 00

@unifolio0 unifolio0 added the BE_INFRA 🚧 백엔드 인프라 label Oct 24, 2024
@unifolio0 unifolio0 added this to the BE 포켓로그 1차 배포 milestone Oct 24, 2024
@@ -78,7 +80,7 @@ private List<PokemonTypeResponse> createTypeResponse(Pokemon pokemon) {
}

private List<PokemonAbilityResponse> createAbilityResponse(Pokemon pokemon) {
List<String> abilityIds = pokemon.getNormalAbilityIds();
List<String> abilityIds = new ArrayList<>(pokemon.getNormalAbilityIds());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

멀티 스레드 테스트를 하며 abilityIds 를 get해서 add하는 로직에서 ConcurrentModificationException이 발생했습니다. 해결하기 위해 서비스 로직에서 복사를 해줬는데 추후 모든 데이터 클래스들에 방어적 복사를 적용하면 좋겠네요 ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE_INFRA 🚧 백엔드 인프라
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants