How resource reclaim works based on share ratio

When resource reclaim based on share ratio is enabled, resources are reclaimed according to share ratio across the entire consumer tree.

Scenario: Three Consumers, 18 slots

Let us use the same example that is used for when the feature is not enabled.

Total share pool: 18 slots

There are three consumers: A, B, C. There are no sub-consumers.

The lowest priority consumer is consumer B.

The share ratio is equal for all consumers (1:1:1).

Example 1: Demand exists for all consumers

All consumers have demand for 6 slots.

Behavior is the same as when resource reclaim based on share ratio is not enabled.

Example 2: No demand for consumer C

Behavior is the same as when resource reclaim based on share ratio is not enabled.

Example 3: Demand exists again for consumer C

Building on the previous example:

Consumer A has demand for 10 slots, allocated 9 slots.

Consumer B has demand for 10 slots, allocated 9 slots.

Consumer C now has demand for 2 slots.

To determine from which consumer slots should be reclaimed, the system looks at the share ratio across the entire consumer tree. The share ratio is 1:1:1.

So, to distribute slots according to share ratio, the system identifies which consumer is the most overallocated. In this case, consumer A is overallocated by 1 slot and consumer B is also overallocated by 1 slot. As a result, the system reclaims 1 slot from each consumer A and B to allocate to consumer C.
To distribute slots according to share ratio, the system identifies which consumer is the most overallocated. In this case, consumer A is overallocated by 1 slot and consumer B is also overallocated by 1 slot. As a result, the system reclaims 1 slot from each consumer (A and B) to allocate to consumer C.

Scenario: sub-consumers, 100 slots

Total share pool: 100 slots

There are two first-level consumers: Consumer A and Consumer B. The share ratio is Consumer A: 1, Consumer B: 4

In Consumer B, we have leaf consumers B1 and B2. The share ratio is: Consumer B1:25, Consumer B2: 75.

Example 1: Only consumer A has demand

Consumer A has demand for 100 slots. Only consumer A has demand, so the total share pool is distributed 100% to Consumer A.
Consumer A has demand for 100 slots. Only consumer A has demand, so the total share pool is distributed 100% to Consumer A.

Example 2: B1 has demand for 500 slots

Building on the previous example, consumer A is now allocated 100 slots.

B1 now has demand for 500 slots.

Since consumer B1 has demand, consumer B is considered to have demand by the system.

The system considers the share ratio across the entire tree to reclaim slots. Consumer A’s ratio is 1, consumer B’s ratio is 4, so out of 100 slots, consumer A should get 20, consumer B, 80.

80 slots are reclaimed from consumer A and allocated to consumer B. Consumer B is a first-level consumer, so its leaf consumers are considered.

Consumer B1 has demand. Consumer B2 has no demand. As a result, consumer B1 gets 100% of the slots (80 slots).
Consumer B1 has demand. Consumer B2 has no demand. As a result, consumer B1 gets 100% of the slots (80 slots).

Example 3: All consumers have demand for slots, B2 has demand for 100 slots

Building on the previous example, consumer A now has no demand. Consumer B1 has demand for 500 and is allocated 100 slots.

B2 now has demand for 100 slots.

As a result, slots need to be reclaimed. The system evaluates the share ratio of the entire consumer tree. There is demand across all consumers.

Consumer B1’s ratio is 25, Consumer B2’s ratio is 75. As a result, consumer B1 should get 25, consumer B2 75. Consumer B1 is currently allocated 100 slots. As a result, 75 slots are reclaimed from B1 and allocated to B2.
Consumer B1’s ratio is 25, Consumer B2’s ratio is 75. As a result, consumer B1 should get 25, consumer B2 75. Consumer B1 is currently allocated 100 slots. As a result, 75 slots are reclaimed from B1 and allocated to B2.