Skip to content

[#29] Redis를 이용해 큐로 재시도 로직 구현 #30

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jia8883
Copy link
Collaborator

@jia8883 jia8883 commented May 18, 2025

Closes #29

수정사항

SummaryGenerationService 클래스의 로직을 보충했습니다. 실패시 큐에 넣는 재시도 로직을 구현했습니다.

추후 고려사항(하지만 현재는 할 생각이 없음)

  • 큐에 무한하게 등록이 될 수 있어서 retryCount 필드를 추가할 수 있습니다. 그래서 일정 횟수 초과 시 폐기하거나 에러 큐로 이동할 수 있습니다.

@jia8883 jia8883 requested a review from heeve1 May 18, 2025 14:58
@jia8883 jia8883 self-assigned this May 18, 2025
- 큐를 넣었기에 관련된 테스트 메소드들을 추가했습니다.

@Scheduled(fixedDelay = 5 * 60 * 1000) // 5분마다 실행
public void processRetryQueue() {
while (true) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

현재 로직에서는 예외가 발생하면 87번 라인을 통해 실패 요청이 다시 Redis 큐에 들어가게 됩니다. 그런데 while(true) 루프 안에서 즉시 다음 요청을 꺼내 재시도하기 때문에, 같은 요청이 반복적으로 빠르게 처리되며 재시도 로직이 계속 순환하게 됩니다.

이 과정에서 재시도마다 DB 접근 등의 리소스가 동반되므로, 만약 지속적으로 실패하는 요청이 있다면 짧은 시간 안에 고빈도 DB 트래픽이 발생하고, 결국 시스템 부하나 장애로 이어질 위험이 있습니다!

따라서 무한 루프를 제한하거나, 실패한 요청에 대해 재시도 간 간격이나 최대 재시도 횟수 등을 도입하는 개선이 필요해 보이는군요. 다시 한번 검토해보시지요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

관련 커밋 올렸습니다. 늦은 시간까지 고생이 많으시네요 쉬엄쉬엄 하셔도 됩니다ㅠ

- 포맷 수정으로 인한 관련 테스트 클래스의 객체 포맷도 수정했습니다.
@jia8883 jia8883 requested a review from heeve1 May 20, 2025 01:30
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.

Redis를 이용한 큐 도입
2 participants