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

Guild Member Updates and Large Bots #6712

Open
HcgRandon opened this issue Mar 15, 2024 · 0 comments
Open

Guild Member Updates and Large Bots #6712

HcgRandon opened this issue Mar 15, 2024 · 0 comments
Labels

Comments

@HcgRandon
Copy link

HcgRandon commented Mar 15, 2024

Description

Hi,
GUILD_MEMBER_UPDATEs are a big problem for large discord bots. A quick primer is when a Large bot updates anything todo with it's profile (https://discord.com/developers/docs/resources/user#modify-current-user) this triggers a GUILD_MEMBER_UPDATE to be sent for every single guild associated with that session across all sessions. I cannot understate how much traffic this is all at once. Especially for bots in Millions of servers. This often overloads underlying hardware and leads to downtime.

This has been an issue for a long time it it means that large bots often cannot and should not update anything todo with their profile. However with the awesome new bot profile improvements (such as gif avatars and banners) this issue is starting to surface as developers are wanting to take advantage of these features.

If this only affected your own bot it wouldn't be so serious and could be planned for but the issue is it doesn't... if you share a large amount of servers with another large scale bot, as often is the case. Them updating their bot profile causes the same problem too occur, GUILD_MEMBER_UPDATE for every single guild you share with them.

TL;DR: Large bots editing their profile causes a GMU in every single server they are in. Fine for users, ddos for bots.

There have been some discussions in the past on how we might approach or fix such an issue but they all boil down to one goal. Taking it from an event per guild per session to an event per session.

Loose idea on how we might fix it:

  • Add a new Gateway event for when bots update their profile ie: BOT_UPDATE
  • BOT_UPDATE would be sent for global profile updates, and GUILD_MEMBER_UPDATE could still be sent for server profiles (if maintaining such a feature for bots is desired), role updates, etc
  • Client libraries would be expected to iterate over their member caches for each guild and patch them, simplified pseudo code of this concept:
session.on('BOT_UPDATE', async (event) => {
    for (guild of session.guilds) {
        const cached = guild.members.find(gm => gm.id === event.d.id);
        cached = { ...cached, ...event.d };
    }
});

Steps to Reproduce

Have/create a large discord application in a few million servers, trigger an update via https://discord.com/developers/docs/resources/user#modify-current-user or through the https://discord.dev dashboard. Observe GUILD_MEMBER_UPDATE for each guild the application is apart of.

Expected Behavior

Some form of de duplication should take place to prevent millions of confirmations (GUILD_MEMBER_UPDATE's) of the same information being delivered to all sessions on a per guild basis

Current Behavior

You recieve a GUILD_MEMBER_UPDATE per guild per session across all sessions.

Screenshots/Videos

No response

Client and System Information

This affects all Discord library clients & OS's

@HcgRandon HcgRandon added the bug label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant