Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 관련 이슈
resolves #17
📝 작업 내용
Discord.js가 내부적으로 Rate Limit을 처리하지만, 라이브러리의 내부 동작에 의존하는 것보다 애플리케이션 레벨에서도 대응을 하는 것이 적절하다고 생각했습니다. 대규모 메시지 전송 시 안정성을 보장하기 위해, Batch 단위로 메시지를 전송하며 1초씩 딜레이를 적용하도록 구현했습니다.
MessageBatchSenderService구현🍇 고민한 부분
Discord.js의 자동 Rate Limit 처리 시 문제 점 & 대응 방법
로깅 시스템을 통해 모니터링하며, 사용자 증가 시 Redis 기반 처리로 확장할 계획입니다.
Discord에서 Rate Limit 대응 방식
공식 문서를 보면, 응답 헤더를 통해 애플리케이션이 직접 Rate Limit을 감지하고 대응해야 하는 것 처럼 보일 수 있는데
고수준 API인 discord.js를 사용하고 있어 직접 @discordjs/rest을 이용한 rate limit 처리를 하지 않아도 됩니다.
graph TD A[discord.js] -->|의존| B[@discordjs/rest] B -->|HTTP 요청 처리| C[Discord API]Discord.js Rate Limit 테스트
하지만 실제로 discord.js 문서에 이에 관한 내용이 없어 rate limit이 신뢰하기 위해 간단하게 테스트 해봤습니다.
Discord.js 공식 문서에서는 Rate Limit 처리 방식에 대한 내용이 없어서 Rate Limit 대응이 실제로 동작하는지 확인하기 위해 간단한 테스트를 진행했습니다.
20개와 100개를 같은 채널에 보내보았고, 공식 문서에 명시된대로 약 5개, 약 50개 이상이 되었을때 딜레이가 걸렸습니다.
20개와 100개 메시지를 동시에 전송 & 타임스탬프를 분석
20개 로그 파일
100개 로그 파일