AlgoMaster Logo

Fairness Pattern in System Design

10 min readUpdated June 5, 2026
Listen to this chapter
Unlock Audio

Fairness Pattern in System Design

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).

Unlock Full Access

What is Fairness?

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:

Scroll
##### Fairness Type##### Description##### Example
EqualEveryone gets the same sharePublic API rate limits
ProportionalShare based on entitlementPaid tier gets 10x free tier
WeightedPriority-based allocationPremium customers first
Max-minMaximize the minimum shareEnsure everyone gets something
Work-conservingUnused quota goes to othersBurst capacity

Where Fairness Is Used

Scroll
##### Domain##### Use Case##### Fairness Goal
Rate LimitingAPI access controlPrevent abuse, ensure availability
Multi-Tenant CloudAWS, Azure, GCPNoisy neighbor isolation
Load BalancingRequest distributionEven server utilization
Ticket SalesTicketmaster, concertsFair access during high demand
Content PlatformsTikTok, YouTubeCreator exposure fairness
AuctionsAd bidding, eBayFair competition
Job SchedulingKubernetes, HadoopFair CPU/memory allocation
Network QoSBandwidth allocationFair throughput per flow
GamingMatchmaking, lootFair matches, fair rewards
QueuesCustomer support, ridesFair wait times

Core Challenges

1. The Noisy Neighbor Problem

One tenant's excessive usage degrades performance for others sharing the same infrastructure.

Solutions:

  • Per-tenant resource quotas
  • Isolation boundaries (separate pools)
  • Throttling and admission control
  • Fair queuing algorithms

2. The Thundering Herd Problem

Many users simultaneously compete for limited resources (concert tickets, flash sales, new product launches).

Solutions:

  • Queuing with random selection
  • Lottery/raffle systems
  • Verified fan programs
  • Rate limiting + virtual waiting rooms

3. The Starvation Problem

Some users or requests never get served because others continuously take priority.

Solutions:

  • Aging (priority increases over time)
  • Guaranteed minimum allocation
  • Fair share scheduling
  • Weighted round-robin

4. The Gaming/Abuse Problem

Users try to exploit fairness mechanisms to gain unfair advantage.

5. Fairness vs Efficiency Trade-off

Strict fairness can reduce overall system throughput.

Example: Strict fairness might give resources to idle users while active users wait.

Fairness Algorithms

Algorithm 1: Token Bucket

Control the rate at which requests are processed with burst capability.

How It Works:

  1. Bucket starts with N tokens (capacity)
  2. Tokens are added at rate R per second
  3. Each request consumes one token
  4. If no tokens available, request is rejected
  5. Bucket never exceeds capacity (allows bursts up to capacity)

Parameters:

Scroll
##### Parameter##### Purpose##### Example
RateSustained throughput100 requests/second
CapacityBurst size500 tokens
##### Pros##### Cons
Allows bursts (good UX)Memory per user
Simple to implementBursts can still cause spikes
ConfigurableBucket synchronization at scale

Best for: API rate limiting, per-user quotas

Algorithm 2: Leaky Bucket

Smooth out bursts by processing at a constant rate.

How It Works:

  1. Requests enter a fixed-size queue (bucket)
  2. Requests are processed (leak) at constant rate
  3. If bucket is full, new requests are dropped
  4. Output is always smooth, regardless of input pattern

Comparison with Token Bucket:

Scroll
##### Aspect##### Token Bucket##### Leaky Bucket
BurstsAllowed up to capacitySmoothed out
Output rateVariableConstant
Use caseUser-facing APIsBackend processing
LatencyLower (immediate)Higher (queued)

Best for: Traffic shaping, smoothing request patterns

Algorithm 3: Weighted Fair Queuing (WFQ)

Allocate bandwidth proportionally to weights.

How It Works:

  1. Each user/flow has a separate queue
  2. Each queue has a weight (entitlement)
  3. Scheduler serves queues proportionally to weights
  4. Empty queues' share redistributed to active queues

Virtual Time Calculation:

##### Pros##### Cons
Proportional fairnessO(log N) per packet
No starvationRequires per-flow state
Work-conservingComplex implementation

Best for: Network bandwidth allocation, multi-tenant APIs

Algorithm 4: Deficit Round Robin (DRR)

Simpler alternative to WFQ with O(1) complexity.

How It Works:

  1. Each queue has a "quantum" (bytes allowed per round)
  2. Each queue tracks a "deficit counter"
  3. In each round, add quantum to deficit
  4. Send packets while deficit >= packet size
  5. Subtract packet size from deficit
  6. Leftover deficit carries to next round
##### Pros##### Cons
O(1) per packetLess precise than WFQ
Simple implementationFairness at round granularity
Low memoryNot ideal for variable packet sizes

Best for: High-speed networking, simple fair scheduling

Algorithm 5: Lottery Scheduling

Randomized fairness through probabilistic ticket allocation.

How It Works:

  1. Each user holds tickets proportional to their share
  2. On each scheduling decision, draw a random ticket
  3. Ticket holder wins that round
  4. Over time, wins converge to ticket proportions

Ticket Operations:

##### Operation##### Use Case
Ticket transferDonate priority to child process
Ticket inflationTrusted users can create tickets
Ticket currenciesHierarchical resource allocation
##### Pros##### Cons
Probabilistically fairShort-term variance
Flexible ticket operationsNot deterministic
Simple implementationMay need many draws to converge

Best for: CPU scheduling, resource allocation, flash sale access

Algorithm 6: Max-Min Fairness

Maximize the minimum allocation across all users.

How It Works:

  1. Start with equal allocation to all users
  2. If a user needs less, give them what they need
  3. Redistribute surplus to users who need more
  4. Repeat until no more redistribution possible
##### Pros##### Cons
No user gets less than fair shareComplex computation
Maximizes minimum allocationMay not maximize utilization
Pareto optimalRequires global knowledge

Best for: Bandwidth allocation, cluster resource scheduling

System Architecture

Multi-Tenant Rate Limiting

Hierarchical Rate Limiting

A request must pass rate limits at every level of the hierarchy.

Distributed Rate Limiting

Scroll
##### Approach##### Accuracy##### Latency##### Complexity
Local onlyPoor (N× actual limit)LowestSimple
Central RedisExact+1-5ms per requestMedium
Sliding window logExact+1-5msMedium
Gossip/eventualGood enoughLowComplex

Fair Queue System (Ticket Sales)

Fairness Mechanisms:

##### Mechanism##### Purpose
Random queue positionArrival time doesn't determine success
Verified fan programPriority for proven fans
Purchase limitsMax tickets per person
Bot detectionCAPTCHA, device fingerprinting
Time-limited sessionsCan't hold spot indefinitely

Domain-Specific Deep Dives

Cloud Multi-Tenancy (AWS-style)

AWS Fairness Mechanisms:

##### Resource##### Fairness Mechanism
EC2 CPUCPU credits (burstable), dedicated instances
EBS IOPSProvisioned IOPS, burst balance
NetworkBaseline + burst bandwidth per instance
API callsToken bucket per service per account
LambdaConcurrency limits per account

Credit-Based CPU Fairness:

Content Platform Fairness (TikTok-style)

Creator Fairness Strategies:

##### Strategy##### How It Works
Initial boostNew content gets baseline impressions
Quality-based scalingGood engagement = more distribution
Diversity injectionMix of creator sizes in every feed
Topic fairnessDon't let one topic dominate
Time decayOlder content gets less priority

Exploration vs Exploitation:

Auction Fairness (Ad Bidding)

Ad Rank Formula:

Fairness Mechanisms:

##### Mechanism##### Purpose
Second-price auctionWinners don't overpay
Quality scoreRelevance matters, not just budget
Budget pacingSpread spend evenly over time
Frequency capsLimit how often same user sees ad
Auction diversityDon't always show same advertiser

Job Scheduling Fairness (Kubernetes/YARN)

Dominant Resource Fairness (DRF):

When jobs need multiple resources (CPU + memory), which dimension determines fairness?

Network QoS Fairness

Weighted Fair Queuing in Networks:

Scroll
##### Traffic Class##### Weight##### Guaranteed Bandwidth
Voice (EF)110 Mbps
Video (AF)550 Mbps
Best Effort440 Mbps

When congested, each class gets proportional share. When not congested, unused bandwidth redistributed.

Comparison of Algorithms

Scroll
##### Algorithm##### Fairness Type##### Complexity##### Best For
Token BucketPer-user limitsO(1)API rate limiting
Leaky BucketSmoothingO(1)Traffic shaping
WFQWeighted proportionalO(log N)Network bandwidth
DRRWeighted proportionalO(1)High-speed networking
LotteryProbabilisticO(1)CPU scheduling
Max-MinMaximize minimumO(N²)Resource allocation
DRFMulti-resourceO(N)Cluster scheduling

Metrics and Monitoring

Key Fairness Metrics

Scroll
##### Metric##### Description##### Target
Jain's Fairness Index0-1 measure of allocation fairness> 0.9
Max/Min RatioRatio of largest to smallest share< 2x
Starvation Rate% of users getting 0 service0%
Wait Time VarianceConsistency of wait timesLow
Quota UtilizationHow much of quota is usedTrack distribution

Jain's Fairness Index:

Monitoring Dashboard

System Design Interview Tips

1. Clarify Requirements

##### Question##### Why It Matters
What resource needs fair allocation?Determines algorithm choice
What is "fair" in this context?Equal vs proportional vs weighted
What is the tenant/user model?Per-user, per-org, hierarchical
What is the request pattern?Bursty vs steady affects algorithm
What is acceptable overhead?Latency budget for fairness checks

2. Start with the Problem

Always describe what unfairness you're preventing:

3. Design for Tiers

4. Mention Trade-offs

##### Trade-off##### Considerations
Fairness vs ThroughputStrict fairness may reduce total capacity
Accuracy vs LatencyDistributed rate limiting adds latency
Simplicity vs PrecisionToken bucket is simpler than WFQ
Memory vs FairnessPer-user state scales with users

5. Reference Real Systems

  • "AWS uses token buckets for API rate limiting with per-account quotas"
  • "Linux uses Completely Fair Scheduler (CFS) for CPU time"
  • "Kubernetes uses Dominant Resource Fairness for pod scheduling"
  • "Ticketmaster uses virtual waiting rooms with randomized queues"

Summary

Key Takeaways:

  1. Fairness is policy-driven. Equal, proportional, weighted, or max-min depends on business requirements.
  1. Token bucket is your default. For most rate limiting scenarios, token bucket with per-user buckets is the right choice.
  1. Prevent starvation. Any fairness mechanism must ensure no user gets zero service indefinitely.
  1. Work conservation matters. Unused quota should benefit others, not go to waste.
  1. Abuse is inevitable. Design for bad actors: multi-account abuse, bots, gaming the system.
  1. Measure fairness. Use Jain's Fairness Index, max/min ratios, and starvation rates to quantify.

References

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.

Share

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).

Unlock Full Access

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

Quiz

Fairness Quiz

20 quizzes