How does Ticketmaster prevent bots from grabbing all the concert tickets before real fans have a chance? How does AWS ensure one customer's traffic spike doesn't affect other customers? How does TikTok give new creators a fair shot at going viral instead of only promoting established accounts?
The answer is fairness, a critical pattern for ensuring equitable access to resources, opportunities, and outcomes in distributed systems. Without fairness mechanisms, systems devolve into "winner takes all" scenarios where power users, bots, or noisy neighbors dominate at everyone else's expense.
This pattern appears in many system design interviews: rate limiting, load balancing, multi-tenant systems, ticket sales, content distribution, auction systems, resource allocation, and queue management. The interviewer expects you to understand fair scheduling algorithms, how to prevent abuse, and the trade-offs between fairness, throughput, and latency.
In this article, we will explore the fairness pattern in depth, understand different fairness algorithms, and learn how to design equitable systems for various use cases.
If you're enjoying this newsletter and want to get even more value, consider becoming a [paid subscriber](https://blog.algomaster.io/subscribe).
As a paid subscriber, you'll unlock all premium articles and gain full access to all [premium courses](https://algomaster.io/newsletter/paid/resources) on [algomaster.io](https://algomaster.io).
Fairness in system design means ensuring that resources, access, or opportunities are distributed equitably among users or tenants according to defined policies.
Fairness is not always about equal distribution. It's about appropriate distribution based on policies:
One tenant's excessive usage degrades performance for others sharing the same infrastructure.
Solutions:
Many users simultaneously compete for limited resources (concert tickets, flash sales, new product launches).
Solutions:
Some users or requests never get served because others continuously take priority.
Solutions:
Users try to exploit fairness mechanisms to gain unfair advantage.
Strict fairness can reduce overall system throughput.
Example: Strict fairness might give resources to idle users while active users wait.
Control the rate at which requests are processed with burst capability.
How It Works:
Parameters:
Best for: API rate limiting, per-user quotas
Smooth out bursts by processing at a constant rate.
How It Works:
Comparison with Token Bucket:
Best for: Traffic shaping, smoothing request patterns
Allocate bandwidth proportionally to weights.
How It Works:
Virtual Time Calculation:
Best for: Network bandwidth allocation, multi-tenant APIs
Simpler alternative to WFQ with O(1) complexity.
How It Works:
Best for: High-speed networking, simple fair scheduling
Randomized fairness through probabilistic ticket allocation.
How It Works:
Ticket Operations:
Best for: CPU scheduling, resource allocation, flash sale access
Maximize the minimum allocation across all users.
How It Works:
Best for: Bandwidth allocation, cluster resource scheduling
A request must pass rate limits at every level of the hierarchy.
Fairness Mechanisms:
AWS Fairness Mechanisms:
Credit-Based CPU Fairness:
Creator Fairness Strategies:
Exploration vs Exploitation:
Ad Rank Formula:
Fairness Mechanisms:
Dominant Resource Fairness (DRF):
When jobs need multiple resources (CPU + memory), which dimension determines fairness?
Weighted Fair Queuing in Networks:
When congested, each class gets proportional share. When not congested, unused bandwidth redistributed.
Jain's Fairness Index:
Always describe what unfairness you're preventing:
"Without fairness controls, a single tenant could consume all our API capacity, causing latency spikes for everyone else. We need per-tenant rate limiting with fair queuing to ensure equitable access."
Key Takeaways:
Thank you for reading!
If you found it valuable, hit a like and consider subscribing for more such content every week.
If you have any questions or suggestions, leave a comment.
This post is public so feel free to share it.
P.S. If you're enjoying this newsletter and want to get even more value, consider becoming a [paid subscriber](https://blog.algomaster.io/subscribe).
As a paid subscriber, you'll unlock all premium articles and gain full access to all [premium courses](https://algomaster.io/newsletter/paid/resources) on [algomaster.io](https://algomaster.io).
There are [group discounts](https://blog.algomaster.io/subscribe?group=true), [gift options](https://blog.algomaster.io/subscribe?gift=true), and [referral bonuses](https://blog.algomaster.io/leaderboard) available.
Checkout my [Youtube channel](https://www.youtube.com/@ashishps_1/videos) for more in-depth content.
Follow me on [LinkedIn](https://www.linkedin.com/in/ashishps1/) and [X](https://twitter.com/ashishps_1) to stay updated.
Checkout my [GitHub repositories](https://github.com/ashishps1) for free interview preparation resources.
I hope you have a lovely day!
See you soon,
Ashish
20 quizzes