2

I have two different tasks in my flink job Task1 & Task2. T1 needs 10 Parrelisms and T2 needs 2 parrallism, my cluster has two Taskmanager(TM) and each of my task managers have 8 slots. Task1 runs with default task groups and for Task 2 I m setting separate slot-sharing group

Since I had requirements to distribute my talks sots across TM evenly, I added a cluster. evenly-spread-out-slots: true and deploy my application but evenly distributed is not working. Task manager 1 runs 8 (2 from Task2 and 6 from Task1) and Taskmanager 2 runs 4.

My requirement is each task manager should run 6 (5 for Task1 and 1 for Task2)

FOr testing, whether evenly-spread-out-slots: true work runs or not I commented out Task1 and submitted Task2, with this I can see Task2 runs on both TM1 and TM2 with 1 slot each.

Is there any setting to make sure evenly distributions happen for both the task groups?

scoder
  • 2,451
  • 4
  • 30
  • 70

2 Answers2

2

I had a similar problem with even slots distribution and ended up utilizing the Fine-Grained Resource Management.

So, in your case, let's assume that each task manager has 6Gb RAM and 6 cores, for example. Then, in order to have exactly 5 slots for task-1 slot-sharing group per-tm and exactly 1 slot for task-2 slot sharing group per-tm, I used mutual exclusive requirements:

final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

SlotSharingGroup ssgTask1 = SlotSharingGroup.newBuilder("task-1")
  .setCpuCores(1.1)
  .setTaskHeapMemoryMB(10)
  .build();

SlotSharingGroup ssgTask2 = SlotSharingGroup.newBuilder("task-2")
  .setCpuCores(0.1)
  .setTaskHeapMemoryMB(5900)
  .build();

With this specification, task-2 slot sharing group requires slot with 5900MB heap, which almost occupies all the task manager capacity and therefore each task manager is able to allocate at most 1 task-2 slot.

Similarly, task-1 slot sharing group requires 1.1 cpu cores, so with 6 cores in total per-tm, each tm is able to allocate at most 5 task-1 slots.

With this slot sharing groups configuration I always get even slot sharing group slots distribution across all task managers.

Mikalai Lushchytski
  • 1,563
  • 1
  • 9
  • 18
0

With evenly-spread-out-slots: false

  • the scheduler will take slots from TM1 until none remain, and then move on to TM2

With evenly-spread-out-slots: true

  • the scheduler will take slots from the least used TM when there aren’t any other preferences
  • sources don't have preferences
  • the rest of the topology will follow, with consumers preferring to be co-located with their producers

I not sure it's possible to achieve what you're trying to do. But have you tried this without putting task 2 into a separate slot-sharing group?

David Anderson
  • 39,434
  • 4
  • 33
  • 60
  • Yes, Task1 get distributes evenly but both slots of task2 is running on the same taskmanager – scoder Aug 21 '22 at 17:53