[Question]: common setup for jobs that take long
See original GitHub issueMy use-case is that my jobs take around 30 seconds each, and they are very CPU intensive so I only wish to run one per time.
What’s the common setup for this type of scenario ? I’ve tried something akin to the below but it doesn’t appear optimal since the queue will run about 5-10 items in the queue, then get stuck for about 5 minutes in-between.
let last = Date.now();
this.consumer.on('data', async (message) => {
try {
const res = JSON.parse(message.value);
console.log(res);
await new Promise((resolve) => {
setTimeout(() => {
return resolve();
}, 30000);
});
this.consumer.consume(1);
last = Date.now();
} catch (e) {
console.log(e);
this.consumer.consume(1);
last = Date.now();
}
});
setInterval(() => {
if (Date.now() - last > 10000) {
this.consumer.consume(1);
}
}, 60000);
Issue Analytics
- State:
- Created 4 years ago
- Comments:11
Top Results From Across the Web
47 Questions to Ask Network Peers About Their Job - Indeed
Use these 47 questions to help you know what to ask network peers about their jobs.
Read more >50+ Top Interview Questions and Answers in 2022 | The Muse
We've compiled a list of 50+ common interview questions you might be asked—plus advice on how to answer each and every one of...
Read more >How To Answer Interview Questions About Fast-Paced Work ...
What Is Your Dream Job? What Is Your Ideal Work Environment? Why Are You Looking For A New Job? Why Should We Hire...
Read more >Interview Questions About How Much You Work - The Balance
Example Answer #2 While I know this job requires me to work a set number of hours every week, I am always willing...
Read more >38 Smart Questions to Ask in a Job Interview
Questions for your potential boss · How long have you been at the company? · How long have you been a manager? ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
going to close for now. I’m using one of the solutions above
I haven’t played with it enough yet to know. I think the other issue may be better after the connection has been active for quite some time. Still exploring.