TogetherCrew / discord-bot

2 stars 1 forks source link

Implement Job Queue for Message Extraction and Guild Members Fetching #23

Open Behzad-rabiei opened 1 year ago

Behzad-rabiei commented 1 year ago

Description:

To efficiently extract messages from channels and fetch the members list of guilds in our Discord bot, we need to implement a job queue system. This will allow us to process these tasks asynchronously and handle them in a distributed and scalable manner. We are considering two options, Bull and RabbitMQ, as potential job queue solutions.

Tasks to Implement:

1. Research and document Bull job queue

2. Research and document BullMQ job queue

3. Evaluate and choose the appropriate job queue solution

Additional Notes:

References:

cyri113 commented 1 year ago

Why can we not use RabbitMQ work queues?

https://www.rabbitmq.com/tutorials/tutorial-two-python.html

I guess there might be a persistance issue:

Note on message persistence: Marking messages as persistent doesn't fully guarantee that a message won't be lost. Although it tells RabbitMQ to save the message to disk, there is still a short time window when RabbitMQ has accepted a message and hasn't saved it yet. Also, RabbitMQ doesn't do fsync(2) for every message -- it may be just saved to cache and not really written to the disk. The persistence guarantees aren't strong, but it's more than enough for our simple task queue. If you need a stronger guarantee then you can use publisher confirms.

If we implement another service, I recommend BullMQ over Bull (legacy).

In this case, would we couple the Redis instance to this service or make it available for all services? @mehrdadmms

I would also suggest using parent/child jobs, breaking each API request into a separate job.

cyri113 commented 1 year ago

Tagging @amindadgar as this could impact DAOlytics too.

cyri113 commented 1 year ago

@Behzad-rabiei was this completed? or should we move it to another iteration?