관리 메뉴

기억하기 프로젝트

Retryable의 지수 백오프 multiplier 본문

개발이야기/서버

Retryable의 지수 백오프 multiplier

sy89 2020. 11. 25. 13:58

Exponential Backoff 로 재시도 하기 위함이에요. 최초 1초 지연하고, 이후 2배씩 늘려가며 지연을 해요.
Retryable이 기본 3번 시도하니깐, 호출 실패 -> 1초 대기 -> 호출 실패 -> 2초 대기 -> 호출 실패 -> 4초 대기 -> 호출. 이렇게 넘어가겠죠.

SES의 API 호출은 1초에 1건씩 호출 할 수 있다고 해요. (Service quotas in Amazon SES)
운이 나쁘면 여러 곳에서 호출함으로 인해 실패를 할 가능성이 있어요.

그런 이유로 재시도가 필요하고 발송을 제외한 모든 호출에 대해 제한이 있으므로, 조금씩 재시도 타이밍의 차이를 두기 위함입니다.
요청량이 많아진다면 좀 더 진지하게 Jitter 를 도입해서 랜덤성을 좀 더 둬야 겠으나, 지금은 충돌이 자주 발생할 일이 아닌지라 이 정도로 충분하다고 생각됩니다.

참고:

ex. @Retryable(backoff = @Backoff(delay = 1000, multiplier = 2.0))

docs.spring.io/spring-retry/docs/api/current/org/springframework/retry/annotation/Backoff.html

 

Backoff (Spring Retry 1.2.2.RELEASE API)

boolean random In the exponential case (multiplier() > 0) set this to true to have the backoff delays randomized, so that the maximum delay is multiplier times the previous delay and the distribution is uniform between the two values.

docs.spring.io

docs.aws.amazon.com/ko_kr/general/latest/gr/api-retries.html

 

AWS의 오류 재시도 횟수 및 지수 백오프 - AWS 일반 참조

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다. AWS의 오류 재시도 횟수 및 지수 백오프 DNS 서버, 스위치, 로드 밸런서 등 수

docs.aws.amazon.com

devopedia.org/binary-exponential-backoff

 

Binary Exponential Backoff

When multiple entities attempt to gain access to a shared resource, only one of them will succeed. Those who fail wait till the resource becomes available and then retry. But if everyone were to retry at the same time, quite possibly none of them will succ

devopedia.org