# SFQ: Simple, Stateless, Stochastic Fairness

DevFeed: [SFQ: Simple, Stateless, Stochastic Fairness](<https://devfeed.tech/articles/sfq-simple-stateless-stochastic-fairness-12589.md>)

Original publisher: [Read original article](<http://brooker.co.za/blog/2026/02/25/sfq.html>)

Author: Marc Brooker

Published: 2026-02-25T00:00:00Z

Content type: opinion

Language: en

Sources: [Marc Brooker's Blog](<https://devfeed.tech/sources/marc-brooker-s-blog.md>), [Marc Brooker's Blog](<https://devfeed.tech/sources/marc-brooker-s-blog-2.md>)

Topics: [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [distributed-systems](<https://devfeed.tech/topics/distributed-systems.md>), [Remote Procedure Call (RPC)](<https://devfeed.tech/topics/rpc.md>), [Network](<https://devfeed.tech/topics/network.md>), [systems](<https://devfeed.tech/topics/systems.md>)

Tags: [algorithms](<https://devfeed.tech/tags/algorithms.md>), [customer](<https://devfeed.tech/tags/customer.md>), [distributed-systems](<https://devfeed.tech/tags/distributed-systems.md>), [network](<https://devfeed.tech/tags/network.md>), [queuing](<https://devfeed.tech/tags/queuing.md>), [rpc](<https://devfeed.tech/tags/rpc.md>)

## AI overview

The article explains Stochastic Fairness Queuing (SFQ), an algorithm for isolating workloads from different customers and mitigating noisy-neighbor effects with O(1) queues and O(1) time. It contrasts SFQ with per-client fairness queuing, explains hash-based queue assignment and periodic hash perturbation, and discusses applying the approach to network traffic, RPC requests, single-host services, and load balancing across hosts.

## Source excerpt

SFQ: Simple, Stateless, Stochastic Fairness Roll the dice. Paul E. McKenney's 1990 paper Stochastic Fairness Queuing contains one of my favorite little algorithms for distributed systems. Stochastic Fairness Queuing is a way to stochastically isolate workloads from different customers in a way that significantly mitigates the effects of noisy neighbors, with O(1) queues and O(1) time. McKenney starts by describing Fairness Queuing (or queue per client): This fairness-queuing algorithm operates by maintaining a separate first-come-first-served (FCFS) queue for each conversation. ... Since the queues are serviced in a bit-by-bit round-robin fashion ill-behaved conversations that attempt to use more than their fair share of network resources will face longer delays and larger packet-loss rates than well-behaved conversations that remain within their fair share. That's a network packet focused view, but the same thing can apply to RPC requests, for example, just by using a different key (e.g. the authorized customer id). The big downside of this in distributed systems is that it requires O(customers) queues, and the related O(customers) work of doing round-robin across those queues. Stochastic fairness queuing can be most easily understood by comparing it to strict fairness queuing. The major differences are that the queues are serviced in strict round-robin order and that a simple hash function is used to map from source-destination address pair into a fixed set of queues. In SFQ, on the other hand, a fixed set of queues is used (so O(1) queues, not O(customers) queues), and customers are assigned to the queues based on a hash. That's great, but still causes the problem of long-term bad luck. If I end up on a queue with a noisy neighbor, I end up there forever. If two conversations collide, they will continue to collide, resulting in each conversation of the pair persistently receiving less than its share of bandwidth. This situation is deviated by periodically perturbin