Daan
Daan3w ago

Get list of avavailable workers not running jobs

Hi all! We are integrating https://app.windmill.dev/openapi.html#tag/worker/GET/workers/is_default_tags_per_workspace in our flow to check if a worker is available or not (to report in an app). We see things like occupancy , occupancy last X seconds / minutes, etc. but what is the most reliable way to know if a worker is available right now? Thanks!
6 Replies
Daan
DaanOP3w ago
We see this for example "worker_group": "large_8192mb", "wm_version": "v1.437.1-2-g343cd02ad", "occupancy_rate": 0.35248488, "occupancy_rate_15s": 0.0, "occupancy_rate_5m": 0.0, "occupancy_rate_30m": 0.040873528, What does occupancy rate represent here? The total since the worker was launched?
Alper
Alper3w ago
your best bet is to use the occupancy rate with the smalles time frame, so occupancy_rate_15s. the smaller this value, the more likely it is to be free
Daan
DaanOP3w ago
Great, that's what we ended up doing - thanks! Some context: use case: we want to only enable certain actions in the app (using the "disabled" fields) when a background runnable returns a certain result. In this case, we can't "trigger" this background runnable from the app, it should basically "poll" for available workers in the background. How should we most elegantly do this? Is there a "windmill way" of only enabling certain actions if workers are actually available or is the approach: they will be put in a queue always. Can we for example make a flow "fail" if no worker is available & then not queue them?
Daan
DaanOP3w ago
I was trying this now, but I think this only works for scheduled jobs, not for jobs that are started interactively?
No description
Alper
Alper3w ago
Maybe you could create a schedule that runs every second and enable the "no overlaps" toggle. The flow will basically run forever and could read the disabled flags from somewhere and do whatever is enabled
Daan
DaanOP3w ago
ah great, thanks

Did you find this page helpful?