[Question] How to make Bull jobs concurrent #2463
Answered
by
manast
thakee-kochasoft
asked this question in
Q&A
-
DescriptionFor the context, I'm new to Bull and trying to execute a lot of jobs concurrently. But Bull seems like it'll wait for one job to complete. Minimal, Working Test code to reproduce the issue.const Bull = require("bull");
const jobs = new Bull('jobs');
jobs.process(async (job) => {
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
console.log(`start job.id = ${job.id}`);
await wait(3000); // Wait 3 seconds.
console.log(`end job.id = ${job.id}`);
});
void async function main () {
for (let i = 0; i < 10; i++) {
jobs.add({});
}
}(); If I ran this code, it'll take 30 seconds to execute, one job after another. What am I doing wrong and how to make this concurrent? Bull version4.10.1 |
Beta Was this translation helpful? Give feedback.
Answered by
manast
Nov 11, 2022
Replies: 2 comments
-
From the docs on https://github.com/OptimalBits/bull |
Beta Was this translation helpful? Give feedback.
0 replies
-
Also if you are new to Bull you probably should start with BullMQ instead: https://docs.bullmq.io |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
thakee-kochasoft
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also if you are new to Bull you probably should start with BullMQ instead: https://docs.bullmq.io