Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Jobs not working on pm2 #1560

Closed
kevintprod opened this issue Dec 1, 2022 · 9 comments
Closed

Multiple Jobs not working on pm2 #1560

kevintprod opened this issue Dec 1, 2022 · 9 comments

Comments

@kevintprod
Copy link

Hi, I did deploy my web app in AWS ec2 Linux using pm2. However, Upon testing that runs multiple jobs, it only completely processes the latest jobs I've queued. Other jobs have been automatically moved to "Finished".

Here's the screenshot from the Bull Board, As you can see 2 jobs have been processed simultaneously. However, the first job which is 0% has been moved to Finished automatically, and the latest got the process through.
image

@manast
Copy link
Contributor

manast commented Dec 1, 2022

This is not enough information to understand what is going on. Please provide some simple test code that reproduces an issue and we will look into it.

@kevintprod
Copy link
Author

Here is the code:

import { Queue as QueueMQ } from 'bullmq';

//queue
const fileprocessQueue = new QueueMQ(
  'fileprocessQueue',
  CONFIG_REDIS.redisConn_DB
);
//worker
const fileProcessWorkerHandler = async (job, token) => {
  switch (job.name) {
    case 'fileprocessQueue': {
      const { fileId, userId } = job.data;
      const reqdata = {
        processid: job.id,
        fileId,
        userId,
        job,
      };

      //process the job/file
      await ProcessFile(reqdata);
      break;
    }
    default:
      break;
  }
};
//worker config
const fileJobWorker = new Worker('fileprocessQueue', fileProcessWorkerHandler, {
  connection: {
    host: process.env.REDIS_TEST_ENDPOINT,
    port: process.env.REDIS_TEST_PORT,
    password: process.env.REDIS_TEST_PASSWORD,
    enableOfflineQueue: false,
    connectionTimeout: 5000,
    lazyConnect: true,
  },
  concurrency:50
});

//add job to queue
await fileprocessQueue.add('fileprocessQueue', {
fileId,
userEmail;
});

I tried to run jobs simultaneously but I did not work.

@manast
Copy link
Contributor

manast commented Dec 1, 2022

What did not work? what is your expected result and what did you get?

@kevintprod
Copy link
Author

I was expecting to run a job simultaneously. However, It only runs the latest job I've queued and skip the others. Here's the screenshot from the Bull Board. As we can see I've run 2 jobs supposed to run simultaneously but It skips the 1st job and automatically moved to "Finished"

image

@manast
Copy link
Contributor

manast commented Dec 1, 2022

I really cannot make sense of what you write above, please try to explain in a different way.
For example: "I was expecting to run a job simultaneously", one job run simultaneously to what?
" It only runs the latest job I've queued and skip the others", what do you mean with "skip the others"?

Btw, instead of screenshots of Bullboard you should provide actual code that shows an actual issue.

@kevintprod
Copy link
Author

kevintprod commented Dec 1, 2022

I mean, The above screenshot is supposed to run at the same time. But Job ID 5 got skipped. The code is running fine on my local I can run a job at the same time. However, I cannot run a job at the same time in prod using pm2.

@manast
Copy link
Contributor

manast commented Dec 1, 2022

That screenshot does not say anything useful to me. It could be a bug in bullboard or something like that. Please provide the actual code that shows the issue instead so can we look into it.

@kevintprod
Copy link
Author

I did provide the code, and it is above. Please check.

@kevintprod
Copy link
Author

kevintprod commented Dec 2, 2022

Hi, I found a solution on stackoverflow. This might help other devs that are using pm2 for the cluster setup. I'll leave a link
https://stackoverflow.com/questions/50259763/what-is-the-use-of-pm2-scale-option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants