DiscordSRV

DiscordSRV

86.8k Downloads

Timeout caching members with 400k member Discord server

kohlerpop1 opened this issue · 13 comments

commented

Why?

As stated in the developer portal, 'All bots can make up to 50 requests per second to our API'.
However, with the current setup of our discord bot, we are unsure why the bot is sending over 50 requests per second and causing our bot to be temporarily shadow banned. This has caused players that are authenticated and in the discord to be unable to join the minecraft server because it is banned and unable to make API requests.
Would there be any way to figure out and decrease the amount of API requests made by the bot?
We have a discord with over 400,000 members and a bot that is in charge of verifying the user is authenticated and in the discord in order to join the 18+ NSFW server.
I was wondering what the current method of accomplishing this was using this plugin?
Does it currently make requests everytime, or does it have the potential to use ram to cache roles/permissions, or even the potential to use a database to store and retrieve this information rather than making a request to discords API everytime.

What and How?

Plugin should behave the same, but have various ways to save/retrieve information to decrease the amount of API calls.

Are there alternatives?

I am listing a few alternatives because I do not believe that there are any.

Checks

  • I have used the search at least once to check if my idea has already been suggested and perhaps already implemented.

Anything else

No response

commented

It seems that a timeout occurs when JDA tries to cache the server's members, caching 400k members probably isn't well supported.

Many DiscordSRV features rely on users/members being cached to work, currently. So fixing this isn't as easy just disabling the member caching, but not terribly difficult to fix either

commented

The checks aren't optional

commented

We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please join our Discord at https://discordsrv.com/discord and go to the #support channel for help with installing or configuring DiscordSRV.

commented

I am aware that this is probably not the highest priority so I am trying to find other temporary solutions.
We believe that we may be able to speak with Discord support to increase our API usage allowed on a per route basis.
Anyone have ideas of which API route(s) would be causing the bot to exceed the 50 requests per second?

commented

I can't really think of something in DiscordSRV that would make that many requests. I'd suggest enabling JDA debug messages to aid in figuring out what requests are being made,

This can be done by changing Debug: [] in the config.yml to Debug: ["JDA", "UNCATEGORIZED"] and restarting the server (this will cause a lot of debug messages to be logged)

Log messages for API requests should look something like this

[DiscordSRV] [UNCATEGORIZED DEBUG] [JDA] Executing request POST https://discord.com/api/v8/channels/137421286501646336/messages

If you're able to find a route (or routes) which is(/are) being requested a lot, we'll be able to better look into what might be misbehaving/how we could reduce requests being made

commented

We are gonna give this a shot and test it out.
I will let you know here if and when we find any specifically.
If I am unable to find specifics, would you like a log of everything that was debug printed?

commented

So I have news but I am not sure whether it is good or bad.
There are no logs of 'Executing request POST' at all.
However, there are lots of stacktraces claiming timeouts that looks to be due to the 400k members on the discord server.

There are 2 distinct errors I am noticing.
The first is a NPE which I know is very easy to fix.
The second looks to be a timeout exception.
Here is a very condensed version of ~250 lines instead of 500k that was in the log.
https://paste.gg/p/anonymous/ceba837e3aa2487c803bb5f5b32ce3d7
Please let me know if you need anymore information.
If I find anything else or different, I will edit this with an update!

EDIT 1:
We found and identified messages from LuckPerms which identified users being unable to join!
Here is a combination of the first log along with the new information!
https://paste.gg/p/anonymous/836cf773b9d14bd5a1cdfecca64c7eb5

commented

Many DiscordSRV features rely on users/members being cached to work, currently

maybe u can use RestAction to do it without caching, i haven't read the code base yet. I'll see what i can do

RestActions represent web requests. This is why we rely on a cache. Requiring any Discord-provided information to be re-requested any time it's needed would lead to an excessively slow result.

commented

RestActions represent web requests. This is why we rely on a cache. Requiring any Discord-provided information to be re-requested any time it's needed would lead to an excessively slow result.

Heavily case dependant, but generally DiscordSRV has no reason to cache absolutely all server members

commented

RestActions represent web requests. This is why we rely on a cache. Requiring any Discord-provided information to be re-requested any time it's needed would lead to an excessively slow result.

Heavily case dependant, but generally DiscordSRV has no reason to cache absolutely all server members

Agreed, I'm just saying "use RestActions to do it without caching" isn't exactly the solution in this case or in other cases.

commented

Many DiscordSRV features rely on users/members being cached to work, currently

maybe u can use RestAction to do it without caching, i haven't read the code base yet. I'll see what i can do

commented

RestActions represent web requests. This is why we rely on a cache. Requiring any Discord-provided information to be re-requested any time it's needed would lead to an excessively slow result.

Heavily case dependant, but generally DiscordSRV has no reason to cache absolutely all server members

Do you think this is something that can and will be fixed or something that is not planned as it generally does not seem to be an issue for everyone?
I can attempt to fix this myself, but was unsure of really where to begin and did not feel like diving in with no general knowledge of where to start.

commented

I can attempt to fix this myself but was looking for the ideal place to start. Any suggestions or ideas?
Only asking as it is kind of necessary for a friend group of mine and I would like to have it done as quickly as possible.