Skip to content

Commit aa2967d

Browse files
authored
Update gateway.mdx (#7578)
1 parent 463d80c commit aa2967d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/events/gateway.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ As apps grow and are added to an increasing number of guilds, some developers ma
601601
Each shard can only support a maximum of 2500 guilds, and apps that are in 2500+ guilds *must* enable sharding.
602602
:::
603603

604-
To enable sharding on a connection, the app should send the `shard` array in the [Identify](/docs/events/gateway-events#identify) payload. The first item in this array should be the zero-based integer value of the current shard, while the second represents the total number of shards. DMs will only be sent to shard 0.
604+
To enable sharding on a connection, the app should send the `shard` array in the [Identify](/docs/events/gateway-events#identify) payload. The first item in this array should be the zero-based integer value of the current shard, while the second represents the total number of shards.
605605

606606
:::info
607607
The [Get Gateway Bot](/docs/events/gateway#get-gateway-bot) endpoint provides a recommended number of shards for your app in the `shards` field
@@ -615,7 +615,11 @@ To calculate which events will be sent to which shard, the following formula can
615615
shard_id = (guild_id >> 22) % num_shards
616616
```
617617

618-
As an example, if you wanted to split the connection between three shards, you'd use the following values for `shard` for each connection: `[0, 3]`, `[1, 3]`, and `[2, 3]`. Note that only the first shard (`[0, 3]`) would receive DMs.
618+
As an example, if you wanted to split the connection between three shards, you'd use the following values for `shard` for each connection: `[0, 3]`, `[1, 3]`, and `[2, 3]`.
619+
620+
:::info
621+
Gateway events that do not contain a `guild_id` will only be sent to the first shard (`shard_id: 0`). This includes Direct Message (DM), subscription and entitlement events.
622+
:::
619623

620624
Note that `num_shards` does not relate to (or limit) the total number of potential sessions. It is only used for *routing* traffic. As such, sessions do not have to be identified in an evenly-distributed manner when sharding. You can establish multiple sessions with the same `[shard_id, num_shards]`, or sessions with different `num_shards` values. This allows you to create sessions that will handle more or less traffic for more fine-tuned load balancing, or to orchestrate "zero-downtime" scaling/updating by handing off traffic to a new deployment of sessions with a higher or lower `num_shards` count that are prepared in parallel.
621625

0 commit comments

Comments
 (0)