Priority Queue
Priority queues shift scarce capacity toward urgent work.
- ClassRanks work by business-verifiable urgency.
- FairnessSecures capacity or maximum wait for lower classes.
- AgeShows starvation despite total throughput.
Context
Why this is important
The central decision concerns fairness under sustained load.
The invoice queue is hypothetical; currently seven modules run together.
Fairness strategies
The existing shop processes seven modules in a modular monolith. For hypothetical asynchronous invoice generation, legally required corrections are urgent and normal first invoices are regular. Two of ten processing slots remain reserved for regular work; its priority increases after a defined wait. The team generates urgent jobs for an extended period and proves throughput, oldest-message age, and met waiting time for both classes before adopting the rule.
This is how you read the picture
- Class Few classes with admission criteria
- Fairness Quota or aging
- Age Oldest message per class
| Comparison | Strategy | Effect | Risk |
|---|---|---|---|
| Strict priority | Urgent always first | Lowest urgent latency | Starvation of normal work |
| Capacity quota | Share per class | Predictable minimum progress | Unused reservation |
| Aging | Priority rises with time | Bounds maximum age | More complex rule |
Benefits & limitations
Helps if:
- Urgent and normal work have different waiting-time objectives.
- Later processing of normal work remains acceptable.
- Classes can be assigned by stable rules rather than user preference.
Boundaries
- Priority does not replace capacity planning; under overload, total backlog grows.
- Too many classes make rules unclear and encourage arbitrary escalation.
- Strict priority can starve normal work; its maximum wait needs its own SLO.
In practice
- Place urgent correction invoices and routine invoices in separate priority classes. Measure both classes’ waiting time during a sustained urgent workload.
- Apply a limit to urgent messages and check whether routine work starts within its agreed deadline. Reserve worker capacity or a separate lane and document the resulting fairness rule for the normal queue.
- Compare separate queues with one priority queue. Check fairness, reserved capacity, monitoring, and behavior when a priority value is malformed.
Read the detailed explanation
The sender or broker assigns every message to a business-justified class. Within a class, documented broker ordering applies; between classes, the fairness strategy decides.
Sustained high-priority traffic can displace lower classes. Quotas, aging, or reserved consumers make minimum progress for normal work measurable.
Publish-Subscribe distributes events to independent subscribers. Backpressure limits intake when even prioritized processing cannot carry the load.
Check your understanding
Test yourself in three stages
ReadingCheck in the picture
Which metric shows starvation?
View the solution with justification
The age of the oldest message per class.
ApplyingTransferred to a new situation
How does the shop protect normal invoices?
View the solution with justification
Through reserved slots and aging after a defined wait.
EvaluateWeighing an alternative
Why does priority not solve capacity shortage?
View the solution with justification
It changes only order; total backlog keeps growing.
Explore further
These building blocks continue the thoughts of this page.
References
- Azure · Priority Queue Pattern (opens in new tab)Primary documentation relevant to Priority Queue.
- Enterprise Integration Patterns · Priority Channel (opens in new tab)Primary documentation relevant to Priority Queue.
- Amazon SQS · Message Timers (opens in new tab)Primary documentation relevant to Priority Queue.