#Is this a good design for a scalable bot?
13 messages · Page 1 of 1 (latest)
What does this mean?
recently started sharding quickly
The bot jumped in activity and started to feasibly require sharding a lot sooner than I anticipated
Ok. But sharding is the act of spreading out data among database servers, not workloads in general, which it seems you are meaning.
Also, from your "design" it is hard to say if that is good or bad. One thing that sort of sticks out is why the bot is connected to Redis directly.
Ah okay, discord bots call them shards. Basically you run several instances of your bot and each instace of your bot handles a couple thousand servers
Using it as a sort of cache between all of the bots, so if shard 4 makes an API call it can cache it for the other Shards are able to use if needed. Planned on unique time outs on data so it stays fresh, but things like guild settings and such should be mostly persistent and won't need always-live data from the API. IMO saves a few API calls
So, you are in control of the "Bots"? If yes, then it makes sense to me. 🙂
What is the role of RabbitMQ between the cron/queue worker? Why not use Redis for the queueing of work?
Yes, I am in control of the bot
Mainly to learn RabbitMQ, but also to just make sure I have reliable scheduleable work. It seems Rabbit natively supports retries, acks and other stuff that you'd have to build on top of redis with like BullMQ or something. It's mainly to keep track of the timed items in the background where I'm using the Redis for cacheing/lookups
Ok. You noted Cron on the worker. Rabbit won't do Cron Jobs out of the box. BullMQ does and it is built for job-queues, which Rabbit isn't. Just sayin. 😊 I'd go with BullMQ, with the little knowledge I have of your needs.
I'm curious about the types of bots you're managing. Have you implemented sharding before? Will the shard instances be hosted on a single machine, or are you planning to horizontally scale them across multiple servers?