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

Problem Rate-Limiting a Worker #667

Closed
mikebridge opened this issue Jul 29, 2021 · 3 comments
Closed

Problem Rate-Limiting a Worker #667

mikebridge opened this issue Jul 29, 2021 · 3 comments

Comments

@mikebridge
Copy link

mikebridge commented Jul 29, 2021

I'm not seeing my rate limits being applied with BullMQ 1.40.1. I'm following this documentation, and I think this should process one job every 10 seconds, but it seems to process them all as fast as it can:

const queue = new Queue(queueName, REDIS_CON);

const queueScheduler = new QueueScheduler(queueName, REDIS_CON);

const worker = new Worker(queueName, processJob, REDIS_CON, {
  concurrency: 1,
  limiter: { 
    max: 1,
    duration: 10000,
  },
});
@manast
Copy link
Contributor

manast commented Jul 30, 2021

Can you extend the issue with a code snippet that reproduces the issue?

@roggervalf
Copy link
Collaborator

@mikebridge maybe you can use this test case https://github.com/taskforcesh/bullmq/blob/master/src/test/test_rate_limiter.ts#L62-L108 to try to reproduce your issue

@mikebridge
Copy link
Author

Sorry, I think this is an error in the constructor arguments. REDIS_CON is

const REDIS_CON = {
  connection: {
    host: redisHost,
    port: redisPort,
  },
};

So it should be:

const worker = new Worker(queueName, processJob, {
  ...REDIS_CON,
  concurrency: 1,
  limiter: { 
    max: 1,
    duration: 10000,
  },
});

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

No branches or pull requests

3 participants