Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle notifications dropped due to rate limiting #7

Open
rootslinux opened this issue Oct 23, 2018 · 1 comment
Open

Handle notifications dropped due to rate limiting #7

rootslinux opened this issue Oct 23, 2018 · 1 comment

Comments

@rootslinux
Copy link
Owner

If the notification service sends a large number of messages within a short time window, Discord will return a failure response indicating that the message was not accepted due to rate limiting, and will provide a timer in which requests will become accepted again (usually 1-2 seconds). The naive implementation of the current system does not handle failures and simply drops the message completely. This means that we could have the case where notifications are generated but never seen in Discord due to being dropped by the rate limiting response.

To fix this, we need to look at the response generated from the curl call and see if there's a failure due to rate limiting. If so, place the message on a queue and retry later once the limiting period has expired. When a new message is about to be sent, the queue should first be checked and if any messages are in the queue, add the new message to the queue instead of sending. The queue should only hold valid messages. If any other failures occur due to invalid formatting or other issues that will not automatically resolve, the message should be dropped (and possibly logged).

All of this logic should take place in notification_service.php. This is a low priority item as we don't expect rate limiting to be a problem under most circumstances. Although forums that are very active will have a higher likelihood of encountering this problem.

@rootslinux
Copy link
Owner Author

I stumbled upon this tonight from a bot in the Discord API channel describing all the rate limits. The one we care about is REST/POST, which allows for 5 messages sent in a 5 second period. So if forums are generating more activity than 5 events in 5 seconds, they would experience some messages dropped.

REST:
POST Message | 5/5s | per-channel
DELETE Message | 5/1s | per-channel
PUT/DELETE Reaction | 1/0.25s | per-channel
PATCH Member | 10/10s | per-guild
PATCH Member Nick | 1/1s | per-guild
PATCH Username | 2/3600s | per-account
|All Requests| | 50/1s | per-account
WS:
Gateway Connect | 1/5s | per-account
Presence Update | 5/60s | per-session
|All Sent Messages| | 120/60s | per-session

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

No branches or pull requests

1 participant