Fair Share
Table of Contents
This page defines the service architecture pattern Fair Share in the pattern language. Shared capacity is divided among tenants by weight, so one busy tenant cannot starve the others. In ORE Studio the reporting design applies it at three queues: admission, step concurrency and grid dispatch.
1. Also known as
- Fair-share scheduling.
- Weighted fair queuing, its network form.
2. Context
Many tenants share one pool of capacity: workers, slots, grid nodes. Demand is uneven: one tenant fires five hundred reports, another three.
3. Problem
How is shared capacity divided so that every tenant progresses, whatever the others ask for?
4. Forces
- Arrival order lets the largest tenant delay everyone.
- Fixed slices waste capacity a quiet tenant does not use.
- Some tenants pay for more.
- Order within a tenant should still hold.
5. Solution
When capacity frees up, give it to the tenant furthest below its share: the lowest work in flight per unit of weight, skipping a tenant at its cap. Within a tenant, take the oldest waiting item. A quiet tenant's share flows to the busy ones until it has work again.
Figure 1: Fair Share: a free slot goes to the tenant with the least work in flight per unit of weight.
Source: [[./pattern_fair_share.puml][pattern_fair_share.puml]]. Regenerate with
plantuml -tpng doc/knowledge/service_architecture_patterns/pattern_fair_share.puml.
6. Failure handling
| Concern | What the pattern does |
|---|---|
| Errors | A failed item frees its slot like a finished one. |
| Timeouts | Does not apply: the share decides order, not duration. |
| Retries | A retried item waits in its tenant's queue again. |
| Idempotency | Does not apply. |
| Observability | Each tenant's work in flight and wait time are measured. |
7. Pitfalls
- Fairness at one queue only. A fair admission queue in front of a first-come grid still lets one tenant fill the grid.
- Weights nobody revisits. Paid capacity changes; the weights must follow.
- Shares computed per replica. Each replica is fair locally and unfair in total.
8. Security
Availability across tenants: no tenant's load can starve another's.
9. Resulting context
- Benefits
- Every tenant progresses during any peak.
- Liabilities
- The largest tenant waits longer than under arrival order, and weights need care.
10. In ORE Studio
- Report execution at scale — admission, step concurrency and grid dispatch each share capacity across tenants.
- How the compute grid queues and claims work — the claim chooses the next job across tenants.
11. Related patterns
- Queue-Based Load Leveling — the queues the share orders.
- Bulkhead — the pools the share divides.
- Throttling — the caps the share respects.
12. Sources
- J. Kay and P. Lauder, "A Fair Share Scheduler", Communications of the ACM, 31(1), 1988.
- Apache Hadoop, YARN Fair Scheduler.
- Microsoft, Azure Architecture Center, Cloud design patterns, Priority Queue pattern.
13. See also
- Service architecture patterns — the structure note that orders this pattern language, and where to read this page in it.