Skip to content

Conversation

@cjh-19
Copy link
Member

@cjh-19 cjh-19 commented Dec 2, 2024

  • 공지사항 크롤링 요청 총 5번을 비동기 처리로 시간 단축

close: #218

- 공지사항 크롤링 요청 총 5번을 비동기 처리로 시간 단축
@cjh-19 cjh-19 merged commit 602f6ec into develop Dec 2, 2024
1 check passed
@cjh-19 cjh-19 deleted the feature/#218_mainpage_speed branch December 2, 2024 06:25
@cjh-19
Copy link
Member Author

cjh-19 commented Dec 4, 2024

공지사항 기능의 요청을 비동기 처리하여 성능을 개선함.

  • CompletableFuture.supplyAsync()를 사용하여 공지사항 데이터를 병렬로 가져옴
  • 각 카테고리("", "0", "1", "2", "4")의 데이터를 별도로 호출하여 병렬 처리
  • CompletableFuture.allOf()로 동기화 -> 모든 CompletableFuture 작업이 완료될 때까지 대기
  • Future.get()를 사용하여 각 결과를 가져와 MainResponseDto.Notices 객체로 병합

Copy link
Member Author

@cjh-19 cjh-19 left a comment

Choose a reason for hiding this comment

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

공지사항 비동기 처리 코드 리뷰 완료

);
try {
// 공지사항 비동기 호출
CompletableFuture<List<MainResponseDto.NoticeItem>> generalNotices = CompletableFuture.supplyAsync(() ->
Copy link
Member Author

Choose a reason for hiding this comment

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

  1. CompletableFuture.supplyAsync()를 사용하여 공지사항 데이터를 병렬로 가져옴
  2. 각 카테고리("", "0", "1", "2", "4")의 데이터를 별도로 호출하여 병렬 처리

.collect(Collectors.toList())
: List.of();
// 모든 공지사항 작업 완료 대기
CompletableFuture.allOf(
Copy link
Member Author

Choose a reason for hiding this comment

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

  • CompletableFuture.allOf()로 동기화 -> 모든 CompletableFuture 작업이 완료될 때까지 대기

events = (calendarResponseDto != null) ? calendarResponseDto.getEvents() : new CalendarResponseDto.EventGroup();
}
// 공지사항 결과 병합
MainResponseDto.Notices notices = new MainResponseDto.Notices(
Copy link
Member Author

Choose a reason for hiding this comment

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

  • Future.get()를 사용하여 각 결과를 가져와 MainResponseDto.Notices 객체로 병합

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 메인 페이지 업로드 속도 개선

2 participants