Exponential Backoff
점진적으로 시간 간격이 늘어나는 Exponential Backoff 전략
지수에 비례하여 Backoff 시간을 조절한다.
한계점: 어차피 동시에 요청이 몰린다면 똑같은 시간 간격으로 모든 재시도가 동일하게 몰릴 것
With Jitter
원래 Jitter는 데이터 통신 용어로 사용될 때는 패킷 지연이 일정하기 않고, 수시로 변하면서 그 간격이 일정하지 않는 현상을 의미한다
동일한 재시도 시간 간격에 무작위성을 추가하여 서로 요청하는 시간대의 동시성(?)을 분산
지수로 증가하는 Backoff 시간에 일정 범위 안의 랜덤 대기 시간을 추가적으로 더하는 것
On WebFlux
Normal Retry
- .retry()
- .retry(long numRetries)
- .retryWhen(Retry retrySpec)
- .retryWhen(Retry.max(3)) == .retry(3)
- .retryWhen(Retry.fixedDelay(3, Duration.ofMillis(1000)))
Exponential Backoff
- .retryWhen(Retry retrySpec)
- .retryWhen(Retry.backoff(3, Duration.ofMillis(2000)))
Jitter
An additional benefit of the backoff strategy is that it adds randomness or jitter to the computed delay interval. Consequently, jitter can help to reduce retry-storms where multiple clients retry in lockstep.
By default, this value is set to 0.5, which corresponds to a jitter of at most 50% of the computed delay.
We should note that the possible range of values is between 0 (no jitter) and 1 (jitter of at most 100% of the computed delay).
- .retryWhen(Retry retrySpec)
- .retryWhen(Retry.backoff(3, Duration.ofMillis(2000)).jitter(0.75))
Reference
https://javacan.tistory.com/entry/Reactor-Start-5-error-handling
https://aws.amazon.com/ko/blogs/architecture/exponential-backoff-and-jitter/
https://www.baeldung.com/spring-webflux-retry#3-retrying-with-jitter
https://www.baeldung.com/resilience4j-backoff-jitter
'개발' 카테고리의 다른 글
How Do I Wrap a Synchronous, Blocking Call (0) | 2023.07.04 |
---|---|
Thread Pool (0) | 2023.07.03 |
[Redis] Replication / Cluster / Sentinel (0) | 2023.06.18 |
메시지 전달 보증 (Message Delivery Guarantee) (0) | 2023.06.18 |
Redis Fragmentation (0) | 2023.06.18 |