Guide: Implementing a Sharding Strategy #65
Locked
switchupcb
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This guide provides the information required to implement an alternative Discord Bot sharding strategy compared to the strategies outlined in The Disgo Shard Manager.
Terminology
What is an application?
An application refers to a built binary that is executed on your computer. You run applications through the terminal (i.e
run.exe
) or via visual shortcuts.In the context of this explanation, an application refers to the code that your Discord Bot uses to run on a server.
What is an instance?
An instance is a running application.
Instances can be run on a single server or spread among multiple servers.
What is a server?
A server is a computer (with a specialized use-case). You run applications on computers.
A discord bot application is hosted (ran) on a server.
What is a guild?
Guilds in Discord represent an isolated collection of users and channels: These are often referred to as "servers" in the User Interface (UI). However, these "servers" are NOT the same as the servers described above.
A Discord guild is a concept, while a server is a physical or virtual machine.
Alternative Sharding Strategies
Service Architecture (Event Architecture)
Implementing a service architecture in a Discord Bot is equivalent to handling incoming events using an instance (codebase) that solely handles specific types of events.
This architecture involves the creation of "Shard Instances" which function as API Gateways to forward incoming event data to respective "Event Handler Instances" (Services) which handle the events.
Shard Instance
Ignoring a shard is equivalent to ignoring all incoming guild event data from that shard. So it's expected that you handle every event from a shard in a Discord Bot instance (unless a load balancer is involved).
The "Shard Instance" is tasked with setting up Discord Sessions and forwarding all incoming events from Discord to an Event Handler instance (likely over the network).
It's not recommended to create event-specific Shard Instances because Discord has over 70 events: Using event-specific Shard Instances implies that you use 70+ instances PER SHARD, each receiving duplicate guild event data.
Event Handler Instance (Service)
The "Event Handler Instance" is tasked with handling incoming events of a specific type.
Beta Was this translation helpful? Give feedback.
All reactions