My Python Discord bot was using 120 MiB of RAM to do basically nothing. I rewrote it in Go. It now uses 6 MiB.
Same features, different language
The bot does:
- Moderation slash commands
- A welcome handler
- A ticket system
- Polling a third-party API every 60s for cached stats
Identical behavior in both versions — same configs, same channels, same outputs.
The numbers
| Metric | Python (discord.py) | Go (discordgo) |
|---|---|---|
| RAM at idle | ~120 MiB | ~6 MiB |
| Cold start | ~2.4s | ~110ms |
| Container image | 380 MB | 18 MB |
| CPU at idle | ~0.5% | ~0.05% |
| Lines of code | ~1,800 | ~1,400 |
The slash command pattern I like
discord.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) {
if i.Type != discordgo.InteractionApplicationCommand {
return
}
switch i.ApplicationCommandData().Name {
case "ping":
respond(s, i, "Pong!")
case "warn":
handleWarn(s, i)
}
})Boring. Predictable. That's the point.
What I miss from Python
- The REPL for one-off message sends.
discord.py's extension reloading is genuinely magical for rapid iteration.- Pretty error messages with full source context.
What Go gives me back
- Single-file deploys.
scp bot ubuntu@server:is the whole pipeline. - The compiler catches the bugs Python hides until 3am on Saturday.
- Memory budget I don't have to think about.
For a 24/7 service on a small VM? Go wins for me.