Hey everyone,
I'm building a Discord bot and want to design it for high scalability from the start – handling many guilds, no arbitrary limits, and graceful recovery when things crash.
Tech stack:
• TypeScript
• PostgreSQL + Drizzle ORM
• BullMQ (Redis) for job queues
My main concern: plugins register background jobs/tasks (reminders, scheduled actions, cron-like stuff, per-guild workloads). If the bot process crashes or restarts, I want:
No jobs lost
In-flight jobs resumed or retried cleanly
The system to scale horizontally across workers as guild count grows
How would you architect this? Specifically:
– Best practices for BullMQ in a multi-worker / multi-guild setup?
– Where should job state live – Redis only, or mirrored in Postgres for durability?
– How do you handle plugin-registered jobs so they auto-rehydrate after a crash?
– Any pitfalls when scaling past a few hundred / thousand guilds?
Appreciate any input, architecture diagrams, or battle-tested patterns! 🙏