[Proposal] Use queues to distribute Actions tasks to runners (but it could be tricky) #24657
Labels
topic/gitea-actions
related to the actions of Gitea
type/proposal
The new feature has not been accepted yet but needs to be discussed first.
Please note that this is not a real proposal.
Instead of discussing "how to use a queue to distribute tasks," I'm going to talk about the difficulties that arise when using a queue to distribute tasks. Despite its potential benefits, there are certain drawbacks that make it not the most effective way to distribute tasks.
This is just my opinion, and I have no objection to others supporting and implementing it. However, I hope them to know some details before doing so.
Background
Tasks are always reminiscent of queues, actually, we did try to use a queue to distribute tasks, but in the end, we did not use this approach. Instead, we only query the database and find a new task when a runner requests one.
However, frequently querying the database can be expensive. It's natural to wonder if we can store tasks in a queue. Querying the queue frequently is much cheaper.
Replace proposal #24544 if this one is feasible.
Before we go any further, let's keep the queue model provided by Gitea in mind. Or we have to rewrite a new implementation.
gitea/modules/queue/base.go
Lines 13 to 20 in b3af748
So
Considered solutions
1. Store all tasks in one queue
It's totally unworkable.
Because tasks could have different
runs-on
, consider the following queue:When a runner labeled windows tries to get a new task, they may receive the wrong task (task 1, runs on ubuntu) or have to wait until task 1 is picked by another runner.
2. Store tasks in multiple queues, each queue is for a specific runner
If we want to do this, we have to assign each task to a specific runner before the runner requests a new task. But that can cause a lot of problems:
3. Store tasks in multiple queues, each queue is for a specific label
I would say it will work fine, but not ideally, because it could be tricky to maintain the set of labels, whether we get the labels from workflow files or registered runners.
After a period of time, the queues could be like:
it's caused by a typo which has already been fixed
it's caused by a test runner which has already been removed
And hundreds of other useless queues
Perhaps the issue could be resolved by periodically cleaning out unnecessary queues. However, how can we distinguish whether a queue is actually unnecessary or not? Maybe
More questions
The text was updated successfully, but these errors were encountered: