question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question]: common setup for jobs that take long

See original GitHub issue

My 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:closed
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
danielb2commented, Dec 11, 2019

going to close for now. I’m using one of the solutions above

1reaction
danielb2commented, Dec 10, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found