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

Rate limit w/ groupKey is not respecting groupKey limit #1322

Closed
kylecannon opened this issue Jul 14, 2022 · 7 comments
Closed

Rate limit w/ groupKey is not respecting groupKey limit #1322

kylecannon opened this issue Jul 14, 2022 · 7 comments

Comments

@kylecannon
Copy link

kylecannon commented Jul 14, 2022

I have a queue that has a concurrency of 10 on the worker but when i have a rate limit with a groupKey of 1, I am only getting a concurrency of 1 and every single job is delayed by 10 seconds. I have verified that the rateLimitKey is unique as well.

Essentially doing the following config below limits concurrency to 1 for a worker with 10 concurrency. Not sure why this is happening.

EX:
queue options:

    defaultJobOptions: {
        backoff: {
            type: 'exponential',
            delay: 2000,
        },
        attempts: 10,
        removeOnComplete: true,
        removeOnFail: true,
    },
    limiter: {
        groupKey: 'rateLimitKey',
    }

worker options:

{
        concurrency: 10,
        autorun: false,
        metrics: {
            maxDataPoints: MetricsTime.ONE_WEEK * 2,
        },
        limiter: {
            groupKey: 'rateLimitKey',
            max: 1,
            duration: 10000,
        },
    }
@manast
Copy link
Contributor

manast commented Jul 15, 2022

@kylecannon do you have a complete test case that we can run?

@kylecannon
Copy link
Author

I don't unfortunately at the moment.

@jamesjjk
Copy link

Any update on the above?

@manast
Copy link
Contributor

manast commented Oct 15, 2022

The limiter based on the group key has its days counted. The implementation is too complex and makes it impossible to implement other optimizations that we want to do on the global rate limiter. On the other hand, we have complete group support in the Pro version, where the rate limit and other features work really well: https://docs.bullmq.io/bullmq-pro/groups

@manast
Copy link
Contributor

manast commented Nov 2, 2022

Here some background information: https://blog.taskforce.sh/bullmq-3-0-release/

@manast manast closed this as completed Nov 2, 2022
@Kylok
Copy link

Kylok commented Nov 4, 2022

I recently updated from BullMQ 1.54.1 to 2.4.0 (the latest 2.X) and the update introduced the issue described by @kylecannon above (large delays are being introduced that don't make sense given the limiting options). I see group-based limiting was explicitly removed in 3.0.0, but it appears at least somewhat broken in 2.X as well.

My queue and worker options are slightly more simple:

Queue options:

	defaultJobOptions: {
		removeOnComplete: true,
		removeOnFail: true
	},
	limiter: {
		groupKey: 'id'
	}

Worker options:

	concurrency: 20,
	limiter: {
		max: 1,
		duration: 250,
		groupKey: 'id'
	}

Reverting back to 1.91.1 (the latest 1.X) fixes the issue.

@manast
Copy link
Contributor

manast commented Nov 4, 2022

@Kylok yes. The reason it was removed was precisely that the implementation was not solid enough. We are not going to spend time trying to fix the issues as there is no guarantee they can be fixed without a rewrite as we did on the Pro version.

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

4 participants