-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Sharding guide #7499
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
Sharding guide #7499
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just copying over my old review comments since they still apply. Also, this document feels a bit short. Not sure what we can do about it at the moment, though.
Sharding | ||
========== | ||
|
||
For bots in a large number of guilds, sharding may be required. Sharding is where a subset of the bot's total guilds are processed in each gateway connection. This allows a bot to handle more events, by splitting them by connection and possibly process. Sharding is generally not recommended for bots in less than 1,000 guilds and is required by Discord when a bot is in over 2,500 guilds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good explanation, but for heading paragraphs I generally recommend trying to break the information into individually digestable, small units. For beginners, it makes the text a bit more approachable, and for novices, it helps quickly determine if the page covers the topic they're expecting.
Not putting all my chips in on this particular presentation, but:
For bots in a large number of guilds, sharding may be required. Sharding is where a subset of the bot's total guilds are processed in each gateway connection. This allows a bot to handle more events, by splitting them by connection and possibly process. Sharding is generally not recommended for bots in less than 1,000 guilds and is required by Discord when a bot is in over 2,500 guilds. | |
When bots start to get considerably large, the amount of events they have to deal with can start to become problematic. | |
At high user and guild counts the incoming messages, typing events, and status updates can start to climb to being as frequent as hundreds per second. | |
To help deal with this large amount of traffic, Discord supports **sharding**, a feature where your bot can split its guilds amongst separate connections, reducing the amount of data each individual connection has to handle. | |
This not only helps Discord by reducing how much data they need to direct to one place, but also helps us, as we can split our bot's overall work across different connections, environments, or even entirely different machines. | |
Discord recommends using sharding once you get over 1,000 guilds, and once you reach beyond 2,500 guilds, it becomes a requirement. | |
Let's discuss what options we have for setting up sharding within discord.py. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I think rewriting it in a form where you can both quickly skim and process/understand it in "chunks" makes it more useful for everyone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we already used "us" and "let's" in other guides? It seems like an important thing to check now to make sure our tone is consistent across the guides. I stuck to avoiding it and using a more typical docs-style tone initially, although since this is a guide, I think either works as long as it's consistent.
We still need to add clustering but I'm unsure how much we actually want to write for that, maybe it could be left for a future PR since the guides project is mostly WIP still and we haven't decided yet? |
Originally posted by @nihaals |
Originally posted by @XuaTheGrate |
Originally posted by @nihaals |
To-do
Client
andAutoShardedClient