H
H
hckn2018-08-20 23:53:01
Node.js
hckn, 2018-08-20 23:53:01

Queues, processes, tasks / tasks - what and when to use?

For the first time, I faced the task of launching programs remotely, in a certain order, at a certain interval. Prior to that, not only had I never worked with queue, messages, etc., but I didn’t even really know what it was. However, I still don't understand, that's why I created this question.
In general, an approximate goal is to have pre-created tasks on the server (actually, ordinary functions), and to be able to programmatically create / delete them through the GUI interface (ie, via API).
My stack is Node, so I chose the Bull library.
And everything works there like this:
a queue is created >> a process is created >> a task is created

const loadBalancerQueue = new Queue('loadbalancer')
loadBalancerQueue.process('requestProfile', 100, requestProfile)
loadBalancerQueue.add('jobA', data, opts)

It seems nothing complicated, but it is completely incomprehensible how to build the application itself?
For example, I have functions (that is, these are actually the final tasks that I want to perform)
1. tweetMonitor() - monitoring a specific Twitter profile (I pass a parameter here dynamically for each task)
2. resizeImage() - loading and resizing in several image sizes
3. convertVideo() - converting the uploaded video
How to be?
For each type of task to create a queue?
Then the problem is that Bull doesn't have an api for getting a list of all queues (I didn't find it)
Or is one server/node instance one queue? And under each type to create process?
Or is it all one process, and in the tasks already specify the type?
At the same time advise plz theories on this topic. I completely overlooked this (but I myself was originally a self-taught front-ender, so ...)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question