mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #250] [FEATURE REQUEST] Ability add workers dynamically on a server #1107
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#1107
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sujit-baniya on GitHub (Mar 11, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/250
Originally assigned to: @hibiken on GitHub.
Currently whenever the task is queued, it creates queue dynamically. For a server to allow to consume the queue, server needs to be stopped, add queue and queue handlers on Mux manually and then start the server.
In my view, creating the workers dynamically is important feature (like in RabbitMQ) without manually intervening server operation.
@hibiken commented on GitHub (Mar 11, 2021):
@sujit-baniya thank you for creating this issue!
I think this is a commonly requested feature. I'll come up with a design/proposal and update this thread again 👍
@sujit-baniya commented on GitHub (Apr 5, 2022):
@hibiken Not sure if it's correct way of adding handler dynamically, this is working for me so far
@realmicro commented on GitHub (Apr 12, 2022):
@sujit-baniya
Can you list the completed code?
Thanks
@sujit-baniya commented on GitHub (Apr 16, 2022):
@realmicro The full code for server.go
https://gist.github.com/sujit-baniya/4d7145c1adb2f97d80955fb31858716e
@ghstahl commented on GitHub (Apr 27, 2022):
Another approach, related to the following https://github.com/hibiken/asynq/issues/439, is to dynamically shutdown the whole server and restart it. The theory is that the server must be in a certain state and the simplest thing for me to do was shut it down and bring it back up with the new settings.
You have to manage the go routine that the asynq server runs in, but that is not that much code.
A scenario with a single app hosting 2 asynq servers:
A first go routine hosts an entire asynq server with all its settings (queues from config 1, what handlers from config 1)
A second go routine hosts an entire asynq server with all its settings (queues from config 2, what handlers from config 2)
Again, it was much simpler to just shut the thing down and restart a given go routine with new settings.
@archit-harness commented on GitHub (Sep 16, 2022):
@sujit-baniya @hibiken were we able to solve this, that we can request dequeue from any given queue name?
@sujit-baniya commented on GitHub (Sep 16, 2022):
@archit-harness I've been using https://gist.github.com/sujit-baniya/4d7145c1adb2f97d80955fb31858716e to solve this. It's working fine as per my need. @hibiken might consider working on it later as per his priority
@archit-harness commented on GitHub (Sep 16, 2022):
Thanks @sujit-baniya for such quick response, i see there are many differences in new server.go file and your file which you have shared, but I think the main difference is added new functions above right? https://github.com/hibiken/asynq/issues/250#issuecomment-1088649898
So basically now our workers can add listening to queues and remove it.
Few Questions -
For first point, what we tried to benchmark is, suppose we create 1k queues having 10 items each and our server has 1k queues to consumer from vs all items in single queue and consumer reading from it, the latter has much better performance.
@archit-harness commented on GitHub (Sep 16, 2022):
But for our use-case we cannot club everything into single queue, as we want to allow the worker to run only X number of tasks for each user.
@archit-harness commented on GitHub (Sep 19, 2022):
@sujit-baniya @hibiken did you get chance to look at my question?
@sujit-baniya commented on GitHub (Sep 19, 2022):
@archit-harness I've not done any benchmarks for my use-case. But I'm using this changes on asynq in on of my products: https://oarkflow.com and working well so far. Multiple Servers and Queues are created on demand and destroyed as required.
@gebv commented on GitHub (Aug 1, 2023):
@hibiken Hi! We need functionality related to dynamic queues with a quality of service (qos) of 1 for each queue. Is there a branch where this work is being carried out? I would like to join in the implementation or contribute in any other way to this feature.