[GH-ISSUE #554] [FEATURE REQUEST] Named Scheduler or Unique ID #263

Open
opened 2026-03-02 05:20:01 +03:00 by kerem · 0 comments
Owner

Originally created by @mirusky on GitHub (Oct 5, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/554

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
Kind of a problem, as documentations suggests:

You can run a Scheduler alongside with the Server to process tasks periodically.

But at same time it says:

You have to ensure only a single scheduler is running for a schedule at a time, otherwise you’d end up with duplicate tasks.

So we can't write the Server and Scheduler at same code when the server scales / has many instances.

Describe the solution you'd like
My proposal is create a UniqueID or Named Scheduler, and asynq checks if there's a scheduler with the given name or id, so in that way even when we scale the Server code with scheduler we don't have the problem of duplicated tasks. Something like:

scheduler := asynq.NewScheduler(
    redisConnOpt, 
    &asynq.SchedulerOpts{
        Name: "my-unique-name",
    },
)

Describe alternatives you've considered
Save in database / redis, how many schedulers are up and if the number is 1, we skip the scheduler. But it's not a safe option since we could create a scheduler and the number of scheduler isn't updated so it create many schedulers and have duplicated tasks.

Additional context
No more context

Originally created by @mirusky on GitHub (Oct 5, 2022). Original GitHub issue: https://github.com/hibiken/asynq/issues/554 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** Kind of a problem, as documentations suggests: > You can run a Scheduler alongside with the Server to process tasks periodically. But at same time it says: > You have to ensure only a single scheduler is running for a schedule at a time, otherwise you’d end up with duplicate tasks. So we can't write the Server and Scheduler at same code when the server scales / has many instances. **Describe the solution you'd like** My proposal is create a UniqueID or Named Scheduler, and asynq checks if there's a scheduler with the given name or id, so in that way even when we scale the Server code with scheduler we don't have the problem of duplicated tasks. Something like: ``` go scheduler := asynq.NewScheduler( redisConnOpt, &asynq.SchedulerOpts{ Name: "my-unique-name", }, ) ``` **Describe alternatives you've considered** Save in database / redis, how many schedulers are up and if the number is 1, we skip the scheduler. But it's not a safe option since we could create a scheduler and the number of scheduler isn't updated so it create many schedulers and have duplicated tasks. **Additional context** No more context
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#263
No description provided.