Skip to content

Discord Bot Operations & Scaling

This guide covers ongoing operations for Discord bot hosting — monitoring, scaling, backups, and best practices for your customers.

Customers can monitor their bots through the portal:

  • CPU Usage: Real-time and historical graphs
  • RAM Usage: Current allocation and trends
  • Network: Inbound/outbound traffic
  • Disk: Storage utilization
  • Uptime: Time since last restart

Recommend customers watch for:

MetricWarningAction Needed
RAM> 75% sustainedOptimize or upgrade plan
CPU> 80% sustainedReview code efficiency or upgrade
Restarts> 5/dayInvestigate crash causes
Disk> 90%Clean logs or upgrade storage

Customers can:

  • View live console output
  • Download log files
  • Clear old logs to free space

Recommend log rotation for bots that generate significant output.

When to upgrade:

  • RAM consistently above 75%
  • CPU spikes causing slow responses
  • Need for MySQL database
  • Running multiple bot processes

Upgrades apply immediately with prorated billing.

For large bots:

  1. Sharding: Split bot across shards using Discord’s sharding system
  2. Microservices: Separate components (commands, music, moderation) into containers
  3. Shared state: Use Redis or MySQL for cross-container data

Discord.js:

const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', {
token: process.env.DISCORD_TOKEN,
totalShards: 'auto'
});
manager.spawn();

discord.py:

from discord.ext import commands
bot = commands.AutoShardedBot(command_prefix='!')

Sharding recommended when approaching 2,500 guilds.

Configure in the portal:

  1. Navigate to Schedules → Create.
  2. Select Backup task type.
  3. Set frequency (daily recommended).
  4. Configure retention (7-30 days typical).
  • Bot source code and configuration files
  • SQLite databases
  • Environment variables
  • Uploaded assets

Before major changes:

  1. Go to Backups in the portal.
  2. Click Create Backup.
  3. Download locally for offsite storage.
  1. Navigate to Backups.
  2. Select the backup to restore.
  3. Choose restore options (files, database, or both).
  4. Confirm and restart the bot.
TaskFrequencyPurpose
RestartDailyClear memory, apply updates
BackupDailyData protection
Dependency updateWeeklySecurity patches
Log cleanupWeeklyFree disk space
  1. Go to Schedules in the portal.
  2. Click Create Schedule.
  3. Configure:
    • Name and description
    • Cron expression or simple interval
    • Command to run
    • Enable/disable toggle

Daily restart:

Command: (use restart action)
Cron: 0 4 * * *

Weekly npm update:

Command: npm update && npm audit fix
Cron: 0 3 * * 0

Advise customers to:

  • Limit Discord.js cache sizes:
const client = new Client({
intents: [...],
makeCache: Options.cacheWithLimits({
MessageManager: 50,
GuildMemberManager: 100
})
});
  • Clear unused data periodically
  • Use external caching (Redis) for large datasets

Discord requires interaction responses within 3 seconds:

  • Use deferReply() for slow operations
  • Cache frequently accessed data
  • Optimize database queries
  • Consider worker processes for heavy tasks
  • Avoid synchronous blocking operations
  • Use connection pooling for databases
  • Implement rate limit handling
  • Profile with debugging tools

Rotate Discord tokens when:

  • Staff members leave
  • Suspicious activity detected
  • Regular quarterly rotation

Process:

  1. Generate new token in Discord Developer Portal
  2. Update environment variable in portal
  3. Restart the bot
  4. Verify connectivity
  • Use environment variables for all secrets
  • Create separate panel accounts for team members
  • Review access logs regularly
  • Remove inactive user permissions

Schedule regular audits:

Node.js:

Terminal window
npm audit
npm audit fix

Python:

Terminal window
pip-audit
pip install --upgrade -r requirements.txt

Review resource usage monthly:

  • Downgrade if utilization stays below 30%
  • Upgrade proactively before performance issues

For customers with multiple small bots:

  • Consider Premium plan with PM2 for multiple processes
  • Share database connections
  • Centralize common functionality

Track peak usage times:

  • Schedule restarts during low activity
  • Plan upgrades before anticipated growth
  • Monitor after feature launches
  1. Check console: Look for error messages and stack traces
  2. Review recent changes: What was deployed or configured recently?
  3. Check resources: Is the container out of memory or CPU?
  4. Rollback if needed: Restore from backup
  5. Contact support: If infrastructure issues suspected

For customers to report issues:

Bot Name: [name]
Server ID: [from portal]
Issue: [description]
When Started: [timestamp]
Recent Changes: [deployments, config changes]
Console Output: [relevant logs]
Steps Taken: [what was tried]
  • Auto-restart enabled
  • Daily backups configured
  • Environment variables secured (hidden)
  • Monitoring thresholds understood
  • Emergency contacts documented
  • Rollback procedure tested
  • Dependencies regularly updated