Skip to content

Halloween sale

40% off the first 2 months of any plan

Applied automatically at checkout.

Ends Nov 1, 2026, 04:55 PM UTC

06days15hr14min06sec
See sale prices

8 candies are hidden in the panel. Find them all and your free Minecraft server gets 4 GB RAM instead of 3.5 GB, for good. Plus +1 GB RAM on a paid server of your choice. Hunt in the panel

Hosting a Discord Bot 24/7: discord.py vs discord.js Memory and Setup

What affects a Discord bot's memory use in discord.py and discord.js, how to measure it yourself, when sharding is required, and how to keep a bot online 24/7.

In this guide
  1. 1. What drives a bot's memory use
  2. 2. Measure it yourself
  3. 3. When you need sharding
  4. 4. Keeping it online 24/7

1. What drives a bot's memory use

For most bots, the language matters less than the cache. Both discord.py and discord.js keep guilds, channels, members and messages in memory so they can answer quickly. The more servers your bot is in, and the more it caches, the more memory it uses.

• Member caching and the privileged members intent are the biggest lever. Only request intents you need. • Message caches grow with activity; cap them. • Your own data (in-memory dictionaries, leaderboards, queues) often outgrows the library itself.

// discord.js: limit caches
const client = new Client({
  intents: [GatewayIntentBits.Guilds],
  makeCache: Options.cacheWithLimits({ MessageManager: 50 }),
});

2. Measure it yourself

Numbers from someone else's bot rarely match yours. Log your own memory once a minute for a day and look at the peak.

• Node.js: process.memoryUsage().rss • Python: resource.getrusage(resource.RUSAGE_SELF).ru_maxrss, or psutil.Process().memory_info().rss

3. When you need sharding

Discord requires sharding once a bot is in 2,500 or more servers. Both libraries support it (AutoShardedClient in discord.py, ShardingManager in discord.js). Below that, a single process is simpler and uses less memory.

4. Keeping it online 24/7

A bot only answers while its process is running, so it needs a host that keeps it up and restarts it if it crashes. Enzonic's free tier runs Discord bots always on, with 512 MB RAM, 50% CPU and 10 GB SSD and no idle sleep, which is enough for most small and medium bots. See https://enzonic.com/discord-bots.

  • Keep your bot token in an environment variable, never in the code you upload or share.