In short
To run multiple Discord bots on one VDS, keep each bot in its own folder with its own .env file, start them all from a single PM2 ecosystem.config.js file, and set a memory limit with max_memory_restart. If you need stricter isolation and CPU limits, run each bot in its own container with Docker Compose. For three or four small bots, 2-4 GB of RAM is usually enough.
In this guide
- Why not get a separate server for each bot?
- Recommended folder structure
- Method 1: Manage bots with a PM2 ecosystem file
- Method 2: Full isolation with Docker
- PM2 or Docker?
- Resource sharing: how bots affect each other
- Update and backup routine
- Choosing a plan by number of bots
- Next step: bring your bots together on one server
The most practical way to run multiple Discord bots on one VDS is to keep each bot in its own folder and manage them all with a single PM2 ecosystem file. If you want stricter separation between bots, you can run each one in its own Docker container with memory and CPU limits. With either method, each bot has its own token, its own .env file, and its own dependencies. This guide covers both methods with setup steps, resource-sharing rules, and how to choose a plan based on how many bots you run.
Why not get a separate server for each bot?
Most Discord bots spend their time waiting: until a message, command, or event arrives, the CPU is nearly idle. A typical moderation or ticket bot runs comfortably on a few hundred MB of RAM. Renting a separate server for every bot wastes resources. Putting your bots on a single VDS:
- Lowers costs and puts management in one place.
- Makes it easy for all bots to share one database (for example, MariaDB or Redis).
- Lets you set up updates, backups, and security settings once.
The trade-off: if one bot leaks memory or pins the CPU, the others are affected too. The methods below are designed to limit exactly that risk.
Recommended folder structure
Whichever method you choose, keep your bots in separate folders. For security, it's also important to run them as a dedicated user instead of root:
sudo adduser --disabled-password --gecos "" botlar
sudo -iu botlar
mkdir -p ~/apps/moderasyon-bot ~/apps/muzik-bot ~/apps/ticket-bot/home/botlar/apps/
├── ecosystem.config.js
├── moderasyon-bot/ (index.js, package.json, .env)
├── muzik-bot/ (index.js, package.json, .env)
└── ticket-bot/ (bot.py, requirements.txt, .venv/, .env)Each bot's token should live only in the .env file in its own folder. A vulnerability in one bot's code shouldn't be able to read the other bots' tokens. We explain why tokens should be kept separate in detail in our Discord bot token security article.
Method 1: Manage bots with a PM2 ecosystem file
PM2 is a process manager built for Node.js, but it can also run processes in other languages like Python. An ecosystem file (ecosystem.config.js) lets you define all your apps, their working directories, and their limits in one place.
- Install Node.js and PM2 (you can install Node.js from your distribution's repository or the official NodeSource repository), then run
npm install -g pm2. - Install dependencies in each bot folder:
npm cifor Node.js bots, andpython3 -m venv .venvplus.venv/bin/pip install -r requirements.txtfor the Python bot. - Create the
~/apps/ecosystem.config.jsfile:
module.exports = {
apps: [
{
name: 'moderasyon-bot',
cwd: '/home/botlar/apps/moderasyon-bot',
script: 'index.js',
max_memory_restart: '300M',
restart_delay: 5000,
env: { NODE_ENV: 'production' }
},
{
name: 'muzik-bot',
cwd: '/home/botlar/apps/muzik-bot',
script: 'index.js',
max_memory_restart: '500M',
restart_delay: 5000,
env: { NODE_ENV: 'production' }
},
{
name: 'ticket-bot',
cwd: '/home/botlar/apps/ticket-bot',
script: 'bot.py',
interpreter: '/home/botlar/apps/ticket-bot/.venv/bin/python',
max_memory_restart: '250M',
restart_delay: 5000
}
]
};- Start the bots and make them start automatically when the server boots:
cd ~/apps
pm2 start ecosystem.config.js
pm2 save
pm2 startup # copy and run the sudo command it printsThe commands you'll need day to day:
pm2 list # status, RAM, and restart count for all bots
pm2 logs muzik-bot # logs for a single bot
pm2 restart ticket-bot # restart a single bot
pm2 reload ecosystem.config.js
pm2 monit # live CPU/RAM monitoringIf a bot leaks memory, the max_memory_restart value restarts only that bot and protects the others. If you're setting up PM2 for the first time, start with our guide to deploying a discord.js bot on a VDS and running it 24/7 with PM2.
Method 2: Full isolation with Docker
Docker runs each app in its own container with its own file system, dependencies, and resource limits. If your bots need different Node.js or Python versions, or you host bots written by other people, Docker is the safer choice.
Put a simple Dockerfile in each bot folder:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
USER node
CMD ["node", "index.js"]Then define all the bots in a single compose.yaml file:
services:
moderasyon-bot:
build: ./moderasyon-bot
env_file: ./moderasyon-bot/.env
restart: unless-stopped
mem_limit: 300m
cpus: "0.5"
muzik-bot:
build: ./muzik-bot
env_file: ./muzik-bot/.env
restart: unless-stopped
mem_limit: 512m
cpus: "1.0"
ticket-bot:
build: ./ticket-bot
env_file: ./ticket-bot/.env
restart: unless-stopped
mem_limit: 256m
cpus: "0.5"docker compose up -d --build
docker compose ps
docker compose logs -f muzik-bot
docker statsA container that exceeds its mem_limit is stopped on its own, and restart: unless-stopped brings it back up. To keep .env files out of your images, add a .dockerignore to each folder and list .env and node_modules in it.
PM2 or Docker?
| Criteria | PM2 ecosystem file | Docker Compose |
|---|---|---|
| Ease of setup | Very easy, a few minutes | Requires Docker knowledge |
| Extra resource usage | Very low | Low, plus extra disk for images |
| Memory limit | Restarts when exceeded (soft) | Hard limit per container |
| CPU limit | None | Yes (cpus) |
| Different runtime versions | Difficult | Easy, each image carries its own version |
| Best for | 2–10 bots you wrote yourself | Bots from different teams, different versions |
Resource sharing: how bots affect each other
- RAM: The resource that runs out most often. Aim to keep the total of your limits under about 80 percent of the server's RAM; the rest is for the operating system and sudden spikes (this is a rule of thumb).
- CPU: Text-based bots use very little CPU. Music bots (especially with Lavalink), image-generating bots, and bots that work heavily with AI APIs need more processing power. Separating these bots with CPU limits protects the others' response times.
- Disk: Log files grow over time. Install the
pm2-logrotatemodule for PM2, and limit log size in Docker. - Network: All bots share the same IP. If one bot sends too many invalid API requests, the IP can be temporarily restricted and every bot goes down. Fix misbehaving bots quickly; for troubleshooting, see our Discord bot keeps going offline guide.
Update and backup routine
When you host multiple bots, the biggest risk is breaking the others while updating one. A simple routine reduces that risk:
- Update bots one at a time: After pulling the code, restart only that bot (
pm2 restart moderasyon-botordocker compose up -d --build moderasyon-bot). Don't restart the whole fleet at once. - Lock your dependencies: Keep
package-lock.jsonandrequirements.txtin version control; usenpm ciinstead ofnpm installon the server. - Back up your data: Set up a daily cron job for your bots' SQLite files or a dump of the shared database, and copy the backup off the server. Store your
.envfiles in your password manager.
Choosing a plan by number of bots
The table below is a starting point for typical bot workloads. Find your exact needs by measuring with pm2 list or docker stats for a few days.
| Scenario | Recommended plan |
|---|---|
| 2–3 small bots (moderation, ticket, logging) | OB-DISCORD-1 or OB-DISCORD-2 |
| 4–6 bots, or a music bot + Lavalink + 2–3 small bots | OB-DISCORD-3 (4 vCPU, 4 GB RAM) |
| Bots + a database + a small web panel, workloads where single-core speed matters | OB-R9-2 (AMD Ryzen 9 5900X, 4 GB RAM), then higher Ryzen plans as you grow |
As your bot fleet grows, running multiple Discord bots on the OB-DISCORD-3 plan with 4 vCPU and 4 GB RAM strikes a comfortable balance for most communities.
Next step: bring your bots together on one server
To set up PM2 or Docker, you need a VDS with root access and real virtualization. OyunBulut's Discord Bot VDS plans come with KVM virtualization, root access, and multi-layer DDoS protection. If you'll host several bots together with Lavalink, start with OB-DISCORD-3. If you're also planning a database, a web panel, or a game server down the road alongside your bots, the OB-R9-2 Ryzen VDS plan with an AMD Ryzen 9 5900X gives you a more flexible foundation; as your needs grow, you can move up to higher plans in the Ryzen Game VDS series.
Frequently asked questions
How many Discord bots can I run on one server?
It depends on the bots' workload. Small moderation or ticket bots run on a few hundred MB of RAM, so a VDS with 4 GB of RAM can comfortably host several of them; music bots need more resources.
Can PM2 run a Python bot?
Yes. If you set the .py file as the script and the Python path inside your virtual environment as the interpreter in the ecosystem file, PM2 manages your Python bot too.
If one bot crashes, do the others go down too?
With PM2 and Docker, each bot is a separate process, so one bot crashing doesn't take down the others. But if one bot uses up all the RAM, the others can be affected, so set a memory limit per bot.
Which is better, PM2 or Docker?
For a few bots you wrote yourself, PM2 is simpler and lighter. If you need different Node.js or Python versions, hard CPU limits, or you host other people's bots, Docker is the better fit.
Is it a problem if my bots share the same IP?
Not under normal use. However, if one bot sends a large number of invalid API requests, the IP can be temporarily restricted and every bot can lose its connection.