Status
Page properties |
---|
This page is meant as a template for writing a FLIP. To create a FLIP choose Tools->Copy on this page and modify with your content and replace the heading with the next FLIP number and a description of your issue. Replace anything in italics with your own description.
Status
...
|
...
|
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Fine-Grained Resource Management
JIRA: here (<- link to https://issues.apache.org/jira/browse/FLINK-XXXX)
Released: <Flink Version>
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Fine-Grained Resource Management is one of Apache Flink’s roadmap features that the community has been trying to deliver. While FLIP-56 delivers the ability to allocate slots with respect to fine-grained resource requirements, the question of how to get those resource requirements remains unanswered. In this FLIP, we will discuss how the runtime interfaces for fine-grained resource requirements should look like, with respect to usability, flexibility and how resources are used in runtime.
...
Code Block | ||||
---|---|---|---|---|
| ||||
public class StreamGraphGenerator {
public StreamGraphGenerator setSlotSharingGroupResource(Map<String, ResourceProfile> slotSharingGroupResources);
} |
The specified SSG resource requirements need to be passed on all the way to the corresponding SlotSharingGroup
in ExecutionGraph
.
Slot Allocation
Currently, slot requests for SSGs are generated by SlotSharingExecutionSlotAllocator
. We propose to make SlotSharingExecutionSlotAllocator
use the resource requirements in corresponding SlotSharingGroup
s
for generating the slot requests.
Related Issues
Network Memory
Network memory is included in the current ResourceProfile
implementation, expecting the fine-grained resource management to not deploy too many tasks onto a TM that require more network memory than the TM contains.
However, how much network memory each task needs highly depends on the shuffle service implementation, and may vary when switching to another shuffle service. Therefore, neither user nor the Flink runtime can easily specify network memory requirements for a task/slot at the moment.
The concrete solution for network memory controlling is beyond the scope of this FLIP. However, we are aware of a few potential directions for solving this problem.
- Make shuffle services adaptively control the amount of memory assigned to each task/slot, with respect to the given memory pool size. In this way, there should be no need to rely on fine-grained resource management to control the network memory consumption.
- Make shuffle services expose interfaces for calculating network memory requirements for given SSGs. In this way, the Flink runtime can specify the calculated network memory requirements for slots, without having to understand the internal details of different shuffle service implementations.
As for now, we propose in FLINK-20863 to exclude network memory from ResourceProfile
for the moment, to unblock the fine-grained resource management feature from the network memory controlling issue. If needed, it can be added back in future, as long as there’s a good way to specify the requirement.
Resource Matching
/**
* Specify fine-grained resource requirements for slot sharing groups.
*
* <p>Note that a slot sharing group hints the scheduler that the grouped operators CAN be
* deployed into a shared slot. There's no guarantee that the scheduler always deploy the
* grouped operator together. In cases grouped operators are deployed into separate slots,
* the slot resources will be derived from the specified group requirement.
*/
public StreamGraphGenerator setSlotSharingGroupResource(Map<String, ResourceProfile> slotSharingGroupResources);
} |
The specified SSG resource requirements need to be passed on all the way to the corresponding SlotSharingGroup
in ExecutionGraph
.
Slot Allocation
Currently, slot requests for SSGs are generated by SlotSharingExecutionSlotAllocator
. We propose to make SlotSharingExecutionSlotAllocator
use the resource requirements in corresponding SlotSharingGroup
s
for generating the slot requests.
Related Issues
Network Memory
Network memory is included in the current ResourceProfile
implementation, expecting the fine-grained resource management to not deploy too many tasks onto a TM that require more network memory than the TM contains.
However, how much network memory each task needs highly depends on the shuffle service implementation, and may vary when switching to another shuffle service. Therefore, neither user nor the Flink runtime can easily specify network memory requirements for a task/slot at the moment.
The concrete solution for network memory controlling is beyond the scope of this FLIP. However, we are aware of a few potential directions for solving this problem.
- Make shuffle services adaptively control the amount of memory assigned to each task/slot, with respect to the given memory pool size. In this way, there should be no need to rely on fine-grained resource management to control the network memory consumption.
- Make shuffle services expose interfaces for calculating network memory requirements for given SSGs. In this way, the Flink runtime can specify the calculated network memory requirements for slots, without having to understand the internal details of different shuffle service implementations.
As for now, we propose in FLINK-20863 to exclude network memory from ResourceProfile
for the moment, to unblock the fine-grained resource management feature from the network memory controlling issue. If needed, it can be added back in future, as long as there’s a good way to specify the requirement.
Resource Matching
Currently, ResourceProfile::isMatching
uses the following rules (hereinafter, loose matching) to decide whether a slot resource can be used to fulfill the given resource requirement, in both SlotManager
and SlotPool
:
...
Currently, with coarse-grained resource management, the scheduler guarantees to always finish fulfilling requirements of one pipeline region before starting to fulfill requirements of another. That means the deadlock case shown on the right of the above figure can never happen..
However, there’s no such guarantee in fine-grained resource management. Since resource requirements for SSGs can be different, there’s no control on which requirements will be fulfilled first, when there are not enough resources to fulfill all the requirements. Therefore, it’s not always possible to fulfill one pipeline region prior to another.
To solve this problem, FLINK-20865 proposes to make the scheduler defer requesting slots for other SSGs before requirements of the current SSG are fulfilled, for fine-grained resource management, at the price of more scheduling time.
Reactive Scheduling
We are aware that fine-grained resource management may not easily work with reactive scheduling, a future feature that is still in planning, that decides the parallelism of execution based on the available resources (as mentioned in FLIP-138).
For fine-grained resource management to work with reactive scheduling, an important open question is which resource requirements should be fulfilled first when there’s not enough resource to fulfill all of them.
The above figure shows a target execution plan on the left that requires 4 slots for each of A and B. On the right, there are 3 possible cases that not all the resource requirements can be fulfilled.
- In Case 1, we get roughly half of the target processing capacity.
- In Case 2, we may only get about 1/4 of the target processing capacity, bottlenecked by B.
- In Case 3, the job cannot be executed at all.
As we can see, how resource requirements are fulfilled with insufficient resources can significantly affect Flink’s performance, and even availability. It could become more complicated when it comes to more complex target execution plans, with heterogeneous target parallelism and scheduling dependencies.
As the first step, we do not support reactive scheduling for However, there’s no such guarantee in fine-grained resource management. Since resource requirements for SSGs can be different, there’s no control on which requirements will be fulfilled first, when there’s not enough resources to fulfill all the requirements. Therefore, it’s not always possible to fulfill one pipeline region prior to another.
To solve this problem, FLINK-20865 proposes to make the scheduler defer requesting slots for other SSGs before requirements of the current SSG are fulfilled, for fine-grained resource management, at the price of more scheduling time.
Reactive Scheduling
We are aware that fine-grained resource management may not easily work with reactive scheduling, a future feature that is still in planning, that decides the parallelism of execution based on the available resources (as mentioned in FLIP-138).
For fine-grained resource management to work with reactive scheduling, an important open question is which resource requirements should be fulfilled first when there’s not enough resource to fulfill all of them.
The above figure shows a target execution plan on the left that requires 4 slots for each of A and B. On the right, there are 3 possible cases that not all the resource requirements can be fulfilled.
- In Case 1, we get roughly half of the target processing capacity.
- In Case 2, we may only get about 1/4 of the target processing capacity, bottlenecked by B.
- In Case 3, the job cannot be executed at all.
As we can see, how resource requirements are fulfilled with insufficient resources can significantly affect Flink’s performance, and even availability. It could become more complicated when it comes to more complex target execution plans, with heterogeneous target parallelism and scheduling dependencies.
As the first step, we do not support reactive scheduling for fine-grained resource management.
In the future, the problem can potentially be resolved along with the following directions.
...
In the future, the problem can potentially be resolved along with the following directions.
- The scheduler may declare a pair of minimum/target required number of slots for each slot resource. In this way, we should always try to allocate the minimum set of resources for executing the job. This should help avoid the worst case (Case 3 in the above example) when it’s possible.
- We may also rely on the scheduler to detect the non-optimal cases (Case 2 & 3 in the above example), and to adjust the declared resource requirements and return unnecessary resources.
Future Plan
Potential follow-up issues
In the discussion, we found that there are some potential issues for fine-grained resource management. The issues recorded below will be done in the future when we collect enough feedbacks from user to prove it is valuable.
Operator-level resource configuration interface
We might provide operator-level resource configuration interfaces for expert users who know the exact resource usage of each operator and also want to control the scheduling strategy in a finer grain.
Default operator resource configuration
In this FLIP, the SSGs with unknown resource requirements will be scheduled with the resource profile of the default slot. We might allow user to configure the default operator resource and schedule those SSGs according to the number of operators inside it.
Known limitations and constraints to be documented
When the fine-grained resource management feature is provided to user, the following limitations and constraints should be well documented, with potential impacts and suggestions.
- Setting chain-able operators to different SSGs may break operator chaining, thus change the performance.
- Change of data exchange mode (pipelined vs. blocking) with in a SSG may affect the resource requirement of the group.
- Parallelism differences between operators in the same SSG may reduce the resource utilization
...
- .