Problem
In a single FIFO queue, a flood of bulk jobs delays time-critical ones. Latency-sensitive work such as password resets waits behind nightly report generation.
Also known as: priority messaging, multi-lane queue
Ensure urgent messages are processed ahead of less important ones, without starving the low-priority work completely.
In a single FIFO queue, a flood of bulk jobs delays time-critical ones. Latency-sensitive work such as password resets waits behind nightly report generation.
A priority queue prevents head-of-line blocking by importance. The robust implementation is separate queues, since in-queue priority flags are weakly supported and hard to observe.
Good policy matters as much as mechanics: decide who may publish at each level and what that level promises.
Broker-native priority support exists in some systems, but with caveats. Priorities are often honored only among messages currently in memory or on a single node, and large backlogs can behave unexpectedly. Separate queues give isolated metrics, separate scaling and clear failure domains, which is why many teams prefer them.
Workers poll lanes by weight. Each cycle takes more from high lanes but always visits low ones, so progress is guaranteed.
lanes = {high: 6, normal: 3, low: 1} # polls per cycle
for lane, n in lanes.items():
for _ in range(n):
msg = queue[lane].poll()
if msg: handle(msg)
Policy deserves as much attention as mechanics. Define what each lane promises, for example high means processed within five seconds at the 99th percentile, and who is allowed to publish there. Rate-limit the top lane so a bug cannot flood it. Also consider reserving a fixed worker slice for high priority so it never waits for capacity to scale up.
Medium - multiple queues or pools
Medium - per-lane scaling and alerts
Low - easy to grasp
Low priority lane starves under constant high-priority load
Everyone marks messages high, erasing the distinction
Broker priority feature reorders unpredictably under load