Skip to content

feat: 429 응답 시 API 키 쿨다운 적용 - #7

Merged
bluelucifer merged 1 commit into
masterfrom
feat/429-cooldown
Feb 14, 2026
Merged

feat: 429 응답 시 API 키 쿨다운 적용#7
bluelucifer merged 1 commit into
masterfrom
feat/429-cooldown

Conversation

@bluelucifer

Copy link
Copy Markdown
Contributor

Summary

  • 429(TOO_MANY_REQUESTS) 응답을 받은 API 키에 쿨다운을 적용하여 rate limit 악화를 방지
  • 업스트림의 Retry-After 헤더를 존중하여 쿨다운 시간 결정
  • 쿨다운 중인 키는 자동으로 건너뛰어 불필요한 재시도 방지

Changes

  • KeyPool에 키별 쿨다운 만료 시각(cooldown_until: AtomicU64) 추가
  • parse_retry_after() 함수로 응답에서 쿨다운 시간 파싱
  • set_cooldown() 메서드로 429 받은 키에 쿨다운 설정
  • acquire()/acquire_excluding()에서 쿨다운 중인 키 자동 제외
  • 쿨다운 기본값: 60초 (Retry-After 헤더 없을 때)
  • 쿨다운 진입/해제를 WARN 레벨로 로깅

Test plan

  • cargo test - 41개 테스트 통과 (기존 37 + 신규 4)
  • cargo build --release - 빌드 성공
  • 실제 운영 환경에서 429 발생 시 쿨다운 로그 확인

🤖 Generated with Claude Code

- KeyPool에 키별 쿨다운 상태(cooldown_until) 추가
- 429 응답 시 Retry-After 헤더 파싱하여 쿨다운 설정
- Retry-After 헤더 없으면 기본 60초 쿨다운 적용
- acquire/acquire_excluding에서 쿨다운 중인 키 자동 건너뜀
- 쿨다운 진입 시 WARN 레벨 로깅

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bluelucifer
bluelucifer merged commit 4dc4fbc into master Feb 14, 2026
1 check passed
@bluelucifer
bluelucifer deleted the feat/429-cooldown branch February 14, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant