Skip to content

[Phase6] Issue #11: SlidingWindowLogService 구현 #11

Description

@724thomas

Phase 목표: 나머지 4개 알고리즘 구현

목표: Sliding Window Log 알고리즘 구현

작업 내용

  • SlidingWindowLogService 클래스 구현
  • 요청 로그 관리 (Queue<Long> 또는 List<Long>)
  • 오래된 요청 정리 로직
  • 메모리 효율성 고려
  • 단위 테스트 작성

완료 기준

  • RateLimiterService 인터페이스 구현
  • 정확한 슬라이딩 윈도우 동작
  • 효율적인 오래된 로그 정리
  • 메모리 사용량 최적화
  • 테스트 커버리지 80% 이상

핵심 로직

  • 모든 요청 시간을 로그로 저장
  • 슬라이딩 윈도우 범위 내 요청만 유지
  • 윈도우 밖의 오래된 요청 제거
  • 현재 윈도우 내 요청 수 계산

알고리즘 특징

  • 장점: 정확한 제한, 버스트 트래픽 평활화
  • 단점: 높은 메모리 사용량, 계산 비용
  • 사용 사례: 정확한 Rate Limiting이 중요한 경우

메모리 최적화

  • 만료된 요청 로그 즉시 제거
  • Queue 사용으로 FIFO 보장
  • 메모리 누수 방지

파일 위치

  • src/main/java/com/example/demo/ratelimiter/service/SlidingWindowLogService.java
  • src/test/java/com/example/demo/ratelimiter/service/SlidingWindowLogServiceTest.java

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions