File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
rate-limiter/src/main/java/io/github/gunkim/ratelimiter/window Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 6
6
import java .util .concurrent .ConcurrentHashMap ;
7
7
import java .util .concurrent .atomic .AtomicInteger ;
8
8
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
+ */
9
21
public class FixedWindowRateLimiter implements RateLimiter {
10
22
private final int maxRequestsPerWindow ;
11
23
private final int windowDurationMillis ;
You can’t perform that action at this time.
0 commit comments