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

perf(worker.ts): lowering the threshold at which blocking redis operation is used to fetch next job #2450

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/classes/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,8 @@ export class Worker<
0,
);

// Blocking for less than 50ms is useless.
if (blockTimeout > 0.05) {
// Blocking for less than 10ms is useless.
if (blockTimeout > this.opts.settings?.blockTimeoutThreshold ?? 0.01) {
blockTimeout = this.blockingConnection.capabilities.canDoubleTimeout
? blockTimeout
: Math.ceil(blockTimeout);
Expand Down
10 changes: 10 additions & 0 deletions src/interfaces/advanced-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@ export interface AdvancedOptions extends AdvancedRepeatOptions {
* A custom backoff strategy.
*/
backoffStrategy?: BackoffStrategy;

/**
* Minimum blocking operation timeout in seconds used when fetching next job.
* If timeout would be smaller than this defined threshold - because of next
* delayed job would be available to be processed sooner - blocking operation
* will not be used.
*
* @defaultValue 0.01
*/
blockTimeoutThreshold?: number;
}