[ Refactor ] - 소비 분류 병렬 처리 및 성능 계측 추가 - #232
Merged
Merged
Conversation
19 tasks
bigwaveBigwave
requested review from
KSBoscoKim,
Kimd0ng,
hanjyoon01 and
shinh09
August 24, 2026 04:38
shinh09
approved these changes
Aug 24, 2026
KSBoscoKim
approved these changes
Aug 24, 2026
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.
관련 이슈
배경
회원가입 후 계좌를 연동하면 사용자의 미분류 거래에 대해 소비 카테고리 분류를 실행합니다.
기존에는 FastAPI 분류 요청을 최대 100건씩 나눈 뒤 순차 호출해, 최초 계좌 연동 완료까지 약 4분이 소요됐습니다. 또한 단계별 처리 시간이 계측되지 않아 정확한 병목과 개선 전후 차이를
확인하기 어려웠습니다.
변경 사항
1. FastAPI 분류 배치 제한 병렬 처리
CallerRunsPolicy를 적용했습니다.2. 병렬도 외부 설정 지원
외부
fastapi.properties에서 병렬도를 조절할 수 있습니다.3. FastAPI timeout 설정
외부 API 지연으로 요청이 무기한 대기하지 않도록 timeout을 추가했습니다.
fastapi.connect-timeout-ms=5000
fastapi.read-timeout-ms=120000
4. 소비 분류 성능 계측 로그 추가
사용자별 실행을 구분할 수 있도록 scope=userId를 포함했습니다.
수집 가능한 지표:
로그 예시:
[일간 소비 분류] FastAPI 배치 완료.
scope=userId=1, page=1, batch=1, requestCount=100,
validCount=100, fallbackCount=0, elapsedMs=...
[일간 소비 분류] 페이지 분류 완료.
scope=userId=1, page=1, targets=..., deterministic=...,
fastApiTargets=..., fastApiBatches=...
[일간 소비 분류] 페이지 저장 완료.
scope=userId=1, page=1, pageSize=..., totalProcessed=...,
dbReadMs=..., classificationMs=..., dbSaveMs=...
[일간 소비 분류] 실행 완료.
scope=userId=1, totalProcessed=..., pages=..., totalElapsedMs=...
기존 동작 유지
테스트
다음 테스트와 패키징을 실행했습니다.
.\gradlew.bat :services:ai-service:test :services:account-service:test --no-daemon
.\gradlew.bat :api:war --no-daemon
결과:
BUILD SUCCESSFUL
추가 및 보강한 테스트:
성능 측정 계획
한 번 배포한 뒤 외부 properties만 변경해 동일 조건에서 비교합니다.
개선 전
fastapi.classification.parallelism=1
개선 후
fastapi.classification.parallelism=4
측정 조건:
비교할 지표:
항목 개선 전 (parallelism=1) 개선 후 (parallelism=4)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━━━
분류 대상 거래 수 측정 예정 측정 예정
─────────────────────────────── ───────────────────────── ─────────────────────────
계좌 연동 전체 시간 p50 / p95 측정 예정 측정 예정
─────────────────────────────── ───────────────────────── ─────────────────────────
소비 분류 전체 시간 p50 / p95 측정 예정 측정 예정
─────────────────────────────── ───────────────────────── ─────────────────────────
처리량(건/초) 측정 예정 측정 예정
─────────────────────────────── ───────────────────────── ─────────────────────────
FastAPI 호출 횟수 측정 예정 측정 예정
─────────────────────────────── ───────────────────────── ─────────────────────────
FastAPI 요청 누적 시간 측정 예정 측정 예정
─────────────────────────────── ───────────────────────── ─────────────────────────
FastAPI wall time 측정 예정 측정 예정
─────────────────────────────── ───────────────────────── ─────────────────────────
fallback 건수 측정 예정 측정 예정
─────────────────────────────── ───────────────────────── ─────────────────────────
미분류 잔여 건수 측정 예정 측정 예정
성능 측정 결과는 배포 후 PR 댓글 또는 이슈 #231에 추가할 예정입니다.
운영 시 확인 사항
fastapi.classification.parallelism=1