Skip to content

Commit d0da51b

Browse files
committed
고정 윈도우 카운터 주석 작성
1 parent 72338d2 commit d0da51b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

rate-limiter/src/main/java/io/github/gunkim/ratelimiter/window/FixedWindowRateLimiter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
import java.util.concurrent.ConcurrentHashMap;
77
import java.util.concurrent.atomic.AtomicInteger;
88

9+
/**
10+
* ## 처리 제한 알고리즘, 고정 윈도우 카운터
11+
* - 고정된 간격의 윈도 내의 요청은 지정된 임계치 만큼 처리한다.
12+
* - 임계치를 넘어선 요청은 새 윈도가 열릴 때까지 버려진다.
13+
* <p>
14+
* 윈도 경계 부근에 순간적으로 많은 트래픽이 집중된다면 할당된 임계치보다 많은 요청이 처리될 수 있는 문제가 있다.
15+
* 예를 들어,
16+
* - 윈도 크기가 1분이고 임계치가 100이라고 가정할 때,
17+
* - 12:00:30에 100개의 요청이 처리되고,
18+
* - 12:01:00에 윈도가 새로 열리면서 다시 100개의 요청이 처리될 수 있다.
19+
* - 이러한 경우 12:00:30에서 12:01:00 사이에 200개의 요청이 처리된 것이다.
20+
*/
921
public class FixedWindowRateLimiter implements RateLimiter {
1022
private final int maxRequestsPerWindow;
1123
private final int windowDurationMillis;

0 commit comments

Comments
 (0)