[GH-ISSUE #889] [FEATURE REQUEST] Custom ticker value for heartbeater duration #1456

Open
opened 2026-03-07 22:09:41 +03:00 by kerem · 4 comments
Owner

Originally created by @RiskyFeryansyahP on GitHub (Jun 2, 2024).
Original GitHub issue: https://github.com/hibiken/asynq/issues/889

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
Currently, in our production environment, I have 9,000 scheduled entries that run once every week and once every month. However, I've noticed that the CPU utilization on my Redis spikes continuously. You can see this in the image below.

When I investigated the reason for these CPU spikes, I disabled the scheduler in asynq, and the CPU usage returned to normal. While examining the code for the scheduler in asynq, I found that the heartbeater inside asynq runs every 5 seconds (hardcoded) using a ticker. This process involves scanning through cron entries and performing WriteSchedulerEntries.

Screenshot 2024-06-02 at 15 43 43

Describe the solution you'd like
I have an idea to configure the ticker duration based on SchedulerOpts. This way, the ticker duration is not hardcoded and can be defined through configuration when initializing NewPeriodicTaskManager.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Originally created by @RiskyFeryansyahP on GitHub (Jun 2, 2024). Original GitHub issue: https://github.com/hibiken/asynq/issues/889 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** Currently, in our production environment, I have 9,000 scheduled entries that run once every week and once every month. However, I've noticed that the CPU utilization on my Redis spikes continuously. You can see this in the image below. When I investigated the reason for these CPU spikes, I disabled the scheduler in `asynq`, and the CPU usage returned to normal. While examining the code for the scheduler in `asynq`, I found that the heartbeater inside `asynq` runs every 5 seconds ([hardcoded](https://github.com/hibiken/asynq/blob/master/scheduler.go#L271)) using a ticker. This process involves scanning through cron entries and performing [WriteSchedulerEntries](https://github.com/hibiken/asynq/blob/master/scheduler.go#L302). <img width="1403" alt="Screenshot 2024-06-02 at 15 43 43" src="https://github.com/hibiken/asynq/assets/36788585/c3f9d54a-f5d2-422e-93fb-136c6f61889e"> **Describe the solution you'd like** I have an idea to configure the ticker duration based on `SchedulerOpts`. This way, the ticker duration is not hardcoded and can be defined through configuration when initializing `NewPeriodicTaskManager`. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here.
Author
Owner

@RiskyFeryansyahP commented on GitHub (Jun 2, 2024):

Hi @hibiken, if you agree with my proposal, I would be happy to implement it 😄

<!-- gh-comment-id:2143760110 --> @RiskyFeryansyahP commented on GitHub (Jun 2, 2024): Hi @hibiken, if you agree with my proposal, I would be happy to implement it 😄
Author
Owner

@RiskyFeryansyahP commented on GitHub (Jun 3, 2024):

Hi @kamikazechaser, if you have time, please check my proposal request 🙏

<!-- gh-comment-id:2144653865 --> @RiskyFeryansyahP commented on GitHub (Jun 3, 2024): Hi @kamikazechaser, if you have time, please check my proposal request 🙏
Author
Owner

@RiskyFeryansyahP commented on GitHub (Jun 29, 2024):

Any update guys?

<!-- gh-comment-id:2198053602 --> @RiskyFeryansyahP commented on GitHub (Jun 29, 2024): Any update guys?
Author
Owner

@Aldiwildan77 commented on GitHub (Jul 14, 2024):

Is there any update for this @hibiken?

Your issue seems fit to me, I also had this when I had a thousand jobs

<!-- gh-comment-id:2227278266 --> @Aldiwildan77 commented on GitHub (Jul 14, 2024): Is there any update for this @hibiken? Your issue seems fit to me, I also had this when I had a thousand jobs
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#1456
No description provided.