Go slowly   About  Contact  Archives

SQS Simple Fair Queuing

In a system with different user workloads, fairness is a must, unless you honestly want the big fish to consume all the resources and let the smaller ones wait in line.

There are many fair-queuing algorithms out there, mostly constructed to solve the fairness in network schedulers. But for simple web applications, we only need a 2-queues system to solve the fairness problem:

Fortunately, AWS SQS comes with the dead-letter queues feature that fits nicely in our use case. Let’s create 2 queues, one dead-letter queue as the regular queue, and another queue as the priority queue, with a redrive policy that set max receive to 1 and dead-letter queue to the regular.

The fairness logic should be clear now:

Written on June 16, 2023.