Conversation
Release: 전반적인 코드 리팩터링 및 IP 화이트 리스트를 통한 모니터링 도구 접근 제한
- Async 비동기 방식 전환을 위한 Config 설정했습니다. - 코어 풀 사이즈를 20으로 설정했습니다. - 맥스 풀 사이즈를 50으로 설정했습니다. - 대기 큐 용량을 100으로 설정했습니다. issue #52
- Async 어노테이션을 활용하여 비동기 통신으로 전환했습니다. - CompletableFuture 반환형을 모든 메서드에 적용했습니다. - 트랜잭션을 분리하기 위해서 Persistence 작업을 위한 서비스를 따로 분리했습니다. issue #52
There was a problem hiding this comment.
Pull Request Overview
This PR converts the travel analysis service from synchronous to asynchronous processing using @Async and CompletableFuture. The goal was to improve performance under concurrent load, though the PR description notes that the change actually resulted in higher failure rates and increased heap usage.
- Introduced async processing with custom thread pool configuration
- Refactored service layer to return
CompletableFuturetypes - Added new persistence service to separate concerns
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| application.yml | Increased max-request-size and updated OpenAI model version |
| CustomRejectedExecutionHandler.java | New custom handler for thread pool saturation with caller-runs fallback |
| AsyncConfig.java | Thread pool configuration for OpenAI operations |
| RetripService.java | Converted to async processing, removed business logic moved to persistence service |
| RetripPersistenceService.java | New service handling database operations and entity building |
| OpenAiClient.java | Added async annotation and CompletableFuture return type |
| GptImageAnalysisService.java | Updated to work with async CompletableFuture pattern |
| RetripController.java | Modified to handle async responses |
| README.md | Updated project documentation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| try { | ||
| log.info("호출 스레드에서 작업 실행 재시도"); | ||
| r.run(); | ||
| } catch (Exception e) { | ||
| log.error("거부된 작업 재실행 중 오류 발생", e); | ||
| } |
There was a problem hiding this comment.
Running rejected tasks synchronously on the caller thread defeats the purpose of async processing and can cause thread blocking. Consider implementing a proper backpressure mechanism or circuit breaker pattern instead.
| try { | |
| log.info("호출 스레드에서 작업 실행 재시도"); | |
| r.run(); | |
| } catch (Exception e) { | |
| log.error("거부된 작업 재실행 중 오류 발생", e); | |
| } | |
| log.error("거부된 작업이 드롭되었습니다. (Rejected task dropped)"); |
| .exceptionally(throwable -> { | ||
| log.error("전체 처리 과정에서 오류 발생", throwable); | ||
| throw new RuntimeException("여행 분석 처리 중 오류가 발생했습니다: " + throwable.getMessage(), throwable); |
There was a problem hiding this comment.
Throwing an exception inside exceptionally() creates an unhandled exception that will be wrapped in a CompletionException. This should return a default value or use handle() method instead to properly manage the exception flow.
| .exceptionally(throwable -> { | |
| log.error("전체 처리 과정에서 오류 발생", throwable); | |
| throw new RuntimeException("여행 분석 처리 중 오류가 발생했습니다: " + throwable.getMessage(), throwable); | |
| .handle((result, throwable) -> { | |
| if (throwable != null) { | |
| log.error("전체 처리 과정에서 오류 발생", throwable); | |
| throw new RuntimeException("여행 분석 처리 중 오류가 발생했습니다: " + throwable.getMessage(), throwable); | |
| } | |
| return result; |
| return CompletableFuture.failedFuture( | ||
| new RuntimeException("GPT API 호출 중 오류가 발생했습니다: " + e.getMessage(), e) | ||
| ); |
There was a problem hiding this comment.
Wrapping the original exception in a RuntimeException loses the specific exception type information. Consider returning the original exception using CompletableFuture.failedFuture(e) or creating a more specific custom exception type.
| return CompletableFuture.failedFuture( | |
| new RuntimeException("GPT API 호출 중 오류가 발생했습니다: " + e.getMessage(), e) | |
| ); | |
| return CompletableFuture.failedFuture(e); |
- WebClient를 활용하기 위해서 WebFlux 의존성을 추가했습니다. - Apple Silicon 오류를 없애기 위해서 dns-native 의존성을 추가했습니다. - WebClient Config 설정 파일을 구현했습니다. issue #53
#️⃣ 연관된 이슈
#52
📝 작업 내용
개선 전
개선 후
결론
💬 리뷰 요구사항