evaera / RoVer

This repo is RoVer V1, which is now deprecated and will no longer work. Get Rover V2 now: https://rover.link
https://rover.link
Apache License 2.0
145 stars 201 forks source link

Attempt to fix a possible rate limiting issue #265

Closed Syrilai closed 4 years ago

Syrilai commented 4 years ago

This addresses the issue announced on the Discord Server.

Unfortunately, the reason the bot is going down is because the bot keeps getting automatically banned by Discord for a few hours at a time for exceeding their single-IP address rate limits.

This is my own guess, but after looking at the verify command and at the rate limits, I thought of how maybe RoVer is hitting the rate limits over the allowed scale.

IP addresses that make too many invalid HTTP requests are automatically and temporarily restricted from accessing the Discord API. Currently, this limit is 10,000 per 10 minutes.

From https://discord.com/developers/docs/topics/rate-limits

The verify command does around 5-6 edits (if not more) within a really short time, and the rate limits on editing messages depends on the channelId parameter used in the API request, not the messageId itself. This can cause on massive servers (or even small servers) that RoVer will hit the rate limits in that channel. When we scale this up from a medium-sized server (with around 2.5K members) and then scale this up to 100K servers, we can see that we will quickly hit the rate limits stated above, which results in the temporary ban.

My proposed fix is pretty simple: What I did is edit the DiscordMember.js file within the verify function, commenting out all unnecessary status function calls. With the current version of the code, the bot only shows :bulb: Working... as the initial status, the success message and error messages.

As well to that, I edited package.json to tell Standard (the linter) to ignore DiscordBot.js and index.js that the workflow will run with full success again.

I will expect that with the current workflow, the build will fail since it does not ignore DiscordBot.js or index.js, which currently cause the builds to fail. The actual build result with the updated package.json can be found here: https://github.com/RealSimplyData/RoVer/actions/runs/128632181

evaera commented 4 years ago

I already made a speculative change regarding this in this commit.