Priority queues on AWS: Amazon MQ, separate SQS queues, or neither
SQS has no priority field. Choose by how long low-priority work may wait: a queue per priority with its own Lambda concurrency, a broker that serves one pool in strict order, or shedding stale work before it queues.
ON THIS PAGE
SQS has no priority field, and you should choose its replacement by one number: how long low-priority work may wait. If it has a latency target, give each priority its own queue and size its share of consumers for the expected backlog. If it may wait indefinitely while urgent work is queued, a broker with real priorities, Amazon MQ, will serve one shared pool in strict order. If it is worthless once it is late, do not queue it at all: shed it at the door or drop it by age.
Priority only matters in a backlog#
A priority field reorders messages that are waiting. When consumers keep up, nothing waits, and every message is delivered in the order it arrived, whatever its number; RabbitMQ's documentation says as much. So the first question is not which product but whether you have a sustained backlog. If the queue drains inside the latency target, adding priorities buys little. A queue that is always behind has a harder problem: whatever you favour, something else waits, and you have to decide what.
That is why the deciding number is the low-priority wait. Strict priority, where urgent messages always go first, gives the best latency to urgent work and no promise at all to the rest: under steady pressure, low-priority messages wait until the pressure stops.
A queue per priority: reserved lanes#
The native AWS answer is two or three SQS queues and a consumer per queue. With Lambda, that is one event source mapping per queue, each with its own maximum concurrency (from 2 to 1,000):
aws lambda create-event-source-mapping --function-name orders \
--event-source-arn "$URGENT_QUEUE_ARN" --scaling-config MaximumConcurrency=80
aws lambda create-event-source-mapping --function-name orders \
--event-source-arn "$ROUTINE_QUEUE_ARN" --scaling-config MaximumConcurrency=20This is weighting, not priority, and that is its strength. With enough reserved concurrency, routine traffic can use up to twenty concurrent invocations and urgent traffic up to eighty. Their caps protect each class from the other, while each queue can still build its own backlog. The cost is the opposite failure: when urgent traffic is quiet, its eighty lanes sit unused while routine work queues behind its cap, and a spike beyond eighty waits even when some routine capacity is idle. Make the function's reserved concurrency at least the sum of the caps, or Lambda will throttle you before your weights do. Avoid the tempting middle ground, one worker pool that always reads the urgent queue first: it rebuilds strict priority, starvation included, by hand.
A broker with priorities: Amazon MQ#
When you have more than three classes, or one pool of expensive workers that should always pick the most urgent job, a broker that orders messages for you is the better fit. Both of Amazon MQ's engines can:
- ActiveMQ ignores JMS priority until you set
prioritizedMessages="true"on a destination policy. Its KahaDB store, which Amazon MQ uses, only distinguishes three bands: below 4, 4, and above 4. AWS's own example sends at 9, 4 and 0, representing those three bands. - On Amazon MQ for RabbitMQ 4.3, quorum queues can use strict priority across up to 32 levels with
x-max-priority. In 4.2 they had two levels served two to one, which guaranteed normal messages kept moving. AWS's upgrade note warns that strict ordering can now starve them.
Two catches apply to both. Prefetch undoes priority: a consumer holding a full buffer of routine messages works through them before it sees the urgent one that just arrived, so keep prefetch small and accept the throughput cost. And a broker is a server, with an instance size, a maintenance window and a bill whether or not anything is queued, which SQS never asks of you.
Shed it instead#
Some low-priority work loses its value with age: a recommendation refresh, a cache warm, a status notification superseded by the next one. Do not reorder it; throw it away. Read each message's SentTimestamp as you receive it and drop or sideline anything older than it is worth, set a short retention on that queue, or reject the work at the API when ApproximateAgeOfOldestMessage says you are behind. Shedding protects urgent work better than any priority scheme, because the backlog never forms.
And check what "priority" means to whoever asked. If one large tenant is drowning the others, that is fairness, and SQS fair queues handle it on a standard queue: send with a MessageGroupId per tenant and SQS deprioritises the noisy one, with no second queue.
The diagram#
Three ways to handle low-priority work: dedicated capacity, shared workers that take urgent work first, or an admission check for stale requests. Open it in archhy and make a copy to sketch your own classes.
On Google Cloud and Azure#
Neither Pub/Sub nor Service Bus has a priority field either, so reserved lanes are the design that travels. On Google Cloud, publish to one topic with a priority attribute and give each class a subscription filtered on it, with its own subscriber pool. Microsoft's Priority Queue pattern uses a Service Bus topic with SQL-filtered subscriptions and a separate Functions app per subscription, scaled to different instance caps. Microsoft's guide also warns that one pool reading the high queue first can starve the rest.
Moving messages between lanes, or promoting old ones, means some messages arrive twice, so the consumers must be idempotent. For where queues fit in the wider design, see event-driven architecture on AWS, and the messaging services compared across the three clouds.
Reference documentation: SQS event source concurrency, SQS fair queues, Amazon MQ RabbitMQ 4.3, ActiveMQ priority, Pub/Sub filters, Azure Priority Queue pattern.
