Key limits (from Discord's docs)
- At most 2,500 servers per shard. Sharding is mandatory at 2,500+.
- 1,000 IDENTIFY calls per 24 hours, shared across all shards. Resumes don't count. A crash-looping bot can run out.
- How many shards can connect at once is set by
max_concurrencyin the session start limit. - The Get Gateway Bot endpoint returns a recommended shard count.
How to shard in each library
- discord.js:
ShardingManagerstarts one process per shard from your main file (new ShardingManager('./bot.js', { token, totalShards: 'auto' })). Useclient.shard.fetchClientValuesfor totals across shards. - discord.py: swap
commands.Botforcommands.AutoShardedBot. It runs every shard in one process. - JDA: use
DefaultShardManagerBuilder.createDefault(token)in place ofJDABuilder.
Things that change when you shard
- Server counts need adding up across shards.
- Memory and CPU grow with shards, especially with one process per shard in discord.js.
- Startup is staggered by
max_concurrency, so big bots take longer to come fully online. - Rate limits don't multiply. The global HTTP limit (50 requests a second) applies to the bot, not per shard.
Do you need it yet?
If your bot is in fewer than about 2,000 servers, you can leave sharding until later, but write code that doesn't assume one shard. Using AutoShardedBot or ShardingManager with 'auto' early costs very little.
Hosting a growing bot on discordbothost
Sharded bots need memory headroom. discordbothost Pro gives 1 GB and a full vCPU for $1.99/month, and Plus gives 2 GB and 1.5 vCPU for $3.49/month, both at a flat price. Watch the live graphs to see when you need the next step. Paid bots also leave through a different outgoing address from free bots, which helps with rate limits.
Sources
https://discord.com/developers/docs/events/gateway (sharding, session start limits); https://discord.com/developers/docs/topics/opcodes-and-status-codes (4011); https://discord.com/developers/docs/topics/rate-limits. Checked .
Questions
When does a Discord bot need sharding?
Discord requires sharding once a bot is in 2,500 or more servers; each shard can handle at most 2,500 servers. Below that, one connection is fine. Without sharding, a large bot is refused with close code 4011 (Sharding required).
How many shards should I use?
Ask Discord: the Get Gateway Bot endpoint returns a recommended shard count. Libraries such as discord.js's ShardingManager, discord.py's AutoShardedClient and JDA's ShardManager use it automatically.
Does sharding need more RAM?
Each shard holds its own connection and its share of the cache, and process-based sharding (like discord.js's ShardingManager) runs one Node process per shard, so memory grows with shard count.
Sources
Related
Why Does My Discord Bot Keep Going Offline?
7 common reasons a Discord bot goes offline (PC sleep, sleeping free hosts, crashes, memory, bad token, intents, rate limits) and how to fix each.
Updated · 4 min readRender Discord Bot Hosting: Free Limits and Setup
Can Render host a Discord bot? Choose a worker or HTTP service, understand free sleep limits, set build commands and move your bot safely.
Updated · 4 min readHow to Host a Discord Bot for Free (Step by Step)
Host a Discord bot 24/7 for free: create the bot, upload your discord.js, discord.py or JDA code to a free host, set the token, and keep it renewed.
Updated · 3 min read