Skip to content

Commit c9b6087

Browse files
committed
refactor(notify): 메모리 최적화를 위해 스케줄러 재시도 횟수 1회로 감소
FAILED 알림 큐로 인한 메모리 부족 문제 해결, 추후 DEAD_LETTER 비율 모니터링 후 필요시 점진적 증가
1 parent 05181b5 commit c9b6087

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/main/java/com/devkor/ifive/nadab/domain/notification/application/helper/NotificationTransactionHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class NotificationTransactionHelper {
2121

2222
private final NotificationRepository notificationRepository;
2323

24-
private static final int MAX_RETRY_COUNT = 3;
24+
private static final int MAX_RETRY_COUNT = 1; // DEAD_LETTER 비율 모니터링 후 필요시 증가
2525

2626
/**
2727
* EventListener: PENDING → SENDING & fcmSent = true (낙관적 설정, Atomic Operation)

src/main/java/com/devkor/ifive/nadab/domain/notification/application/scheduler/NotificationRecoveryScheduler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class NotificationRecoveryScheduler {
2929

3030
private static final int TIMEOUT_MINUTES = 5;
3131
private static final int BATCH_SIZE = 100;
32-
private static final int MAX_RETRY_COUNT = 3;
32+
private static final int MAX_RETRY_COUNT = 1; // DEAD_LETTER 비율 모니터링 후 필요시 증가
3333

3434
/**
3535
* SENDING 상태 타임아웃 복구

src/main/java/com/devkor/ifive/nadab/domain/notification/application/scheduler/NotificationRetryScheduler.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@ public class NotificationRetryScheduler {
3232
private final NotificationTransactionHelper transactionHelper;
3333

3434
private static final int BATCH_SIZE = 100;
35-
private static final int MAX_RETRY_COUNT = 3;
35+
private static final int MAX_RETRY_COUNT = 1; // DEAD_LETTER 비율 모니터링 후 필요시 증가
3636

3737
/**
3838
* Exponential Backoff 재시도 전략
39-
* - retry_count별 대기 시간:
40-
* 0회: 10초
41-
* 1회: 20초
42-
* 2회: 40초 (최대 3회 재시도)
39+
* - 현재 설정: retry_count 0회만 재시도 (10초 대기)
40+
* - 총 시도 횟수: 2회 (최초 1회 + 재시도 1회)
41+
*
42+
* [향후 확장 가능]
43+
* - DEAD_LETTER 비율이 높으면: {10, 20} (재시도 2회)
44+
* - 더 필요하면: {10, 20, 40} (재시도 3회)
4345
*/
44-
private static final int[] RETRY_DELAYS_SECONDS = {10, 20, 40};
46+
private static final int[] RETRY_DELAYS_SECONDS = {10};
4547

4648
/**
4749
* 알림 재시도
@@ -111,7 +113,7 @@ private void retryFailedNotifications() {
111113
*/
112114
protected int retryFailedByRetryCount(int retryCount, OffsetDateTime now) {
113115
// Exponential Backoff 대기 시간 계산
114-
int delaySeconds = RETRY_DELAYS_SECONDS[Math.min(retryCount, RETRY_DELAYS_SECONDS.length - 1)];
116+
int delaySeconds = RETRY_DELAYS_SECONDS[0];
115117
OffsetDateTime threshold = now.minusSeconds(delaySeconds);
116118

117119
// updated_at < threshold인 FAILED 알림 조회

0 commit comments

Comments
 (0)