Search code examples
cadence-workflowtemporal-workflow

Execute all high priority cadence workflows before any low priority workflows


In the documentation at https://cadenceworkflow.io/docs/03_concepts/02_activities#activity-task-routing-through-task-lists it mentions that multiple priorities are supported by having One task list per priority and having a worker pool per priority. Under that implementation, there may still be low priority workflows that get executed before high priority workflows.

Is it possible to implement a priority system such that not a single workflow going to the low priority worker pool gets executed before the workflows going to the high priority workers are in progress?


Solution

  • In the most cases the priorities are useful not for workflows which are mostly blocked waiting for external events, but for activities.

    If your rate of execution is relatively low you can have a separate "priority queue" workflow that would receive signals with requests to execute a certain activity and then maintain the priority queue of the requests in its memory. Then execute activities reading them from that queue. Upon an activity completion a reply signal would be send to the workflow that requested the execution.