Sharding for bot in a single very large server #6584
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot#6584
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type of feature request
Other
Description of the feature you're suggesting
I use Red in a single server with around 300k members. The server recently had a very large influx of members, >18k in a single day, with a large portion occurring within just a few hours, which ended up leaving me with a full IP ban to discord servers that lasted nearly a full day.
When I reached out to support they responded with the following:
Looking at other issues to figure out how to enable sharding #3096. It seems like it is entirely controlled by server count, not by member count and is out of my control.
What the server mods and I determined was the cause was having the bot send a message with full user info into a channel on join.
I think this is a built in cog? So we disabled it like so:
I'm curious if sharding is something that needs to be implemented based on member count in addition to server count like support is saying, or if maybe the member join logging should be throttled in some way.
Anything else?
No response
Sharding is handled by dpy, not Red. Also, the cog you mention, that is ExtendedModLog which is a 3rd party cog.
To add onto this, Red's default behaviour with discord.py's AutoShardedClient will attempt to get the recommended number of shards from discords' gateway. Theoretically discord should be telling the bot it might need 2 shards instead of 1.
Sending 18k messages in 1 channel in 1 day is a lot and would very easily start hitting discord's rate limits regardless of shard count.
I was afraid that might've been it. I figured it's name would've been
extendedmodlognot justmodlogin the cog list.It is, but we also provide a cog named ModLog. The
modlogcommand though is part of the ExtendedModLog cog, not the built-in ModLog cogYeah 18k in a day probably wasn't ideal anyways. I was thinking of other solutions for joins already.
I just wasn't sure if there was anything from the discord support email that was considered new-ish seeing as all other sharding documentation seems to only mention server count not member count.
If there is no action to be made to Red I'm good with the issue being closed. I just wanted to be sure.
I believe you received incorrect information (or at least, potentially misleading information) from Discord support. Sharding allows your bot to split its workload across multiple processes (potentially including multiple machines) by specifying a flag when starting up the bot and connecting to Discord. When you enable sharding, the servers the bot can see are split up and assigned to particular processes based on the configured number of shards and shard ID specified for that particular bot. Gateway events are then sent to only the process assigned to the shard associated with that specific server (using a formula based on the server ID). There is no way to distribute the load of a single server across multiple shards.
Ref: Discord Developer Docs
As a result, it is impossible for sharding to assist with the particular situation you are describing. Your best bet is to limit the number of ways Red responds to input, limiting it to only the most important features such as moderation and commands. Join notifications and other auxiliary event-based functions should be disabled for a server at that scale. I also will warn you that Red is not optimized for large servers or a large number of servers, rather it is designed to be expansive and customizable. This will cause it to perform worse under these conditions than a bot designed for a single specific task.
BACK IN MY DAY!! (Yes Really me!) I've gotten Red to work on Official Fortnite where the max member cap at the time was 500k, and Fortnite was in its prime, without any real changes. All that was required was a powerful machine to handle all the ingest of data, and us limiting what the bot would do and respond on. Our bot was first and foremost a moderation bot. And then everything else.
So while its not recommended, since its mostly me screaming that its not recommended. It is doable is you drop certain features. Like welcoming, fun activities, etc etc.
Yeah it isn't perfect, but this is not a new setup of the bot. We actually use a mix of bots to handle different aspects and have been slowly moving things off Red as we can. User join logging is probably just the next thing to turn off. We have actually been using Red since 2017 when I took ownership of the Clash of Clans server.
As Flame explained, this is not possible - Discord's sharding partitions the events based on the server ID. To my knowledge, you can't split the load into chunks smaller than a single server's load. The response you got from support seems to contradict that, but I believe this is likely to be a mistake from the support agent who responded to your question.
Since we cannot implement something that the API gateway does not support, I'm going to close this issue.