lucasbru commented on code in PR #20486:
URL: https://github.com/apache/kafka/pull/20486#discussion_r2330103941


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/assignor/StickyTaskAssignor.java:
##########
@@ -193,6 +196,9 @@ private void assignActive(final Set<TaskId> activeTasks) {
             }
         }
 
+        // To achieve an initially range-based assignment, sort by subtopology
+        
activeTasks.sort(Comparator.comparing(TaskId::subtopologyId).thenComparing(TaskId::partition));
+

Review Comment:
   Yes. I should clarify in the comment that this mostly applies to the case 
where the number of partitions is a multiple of the number of nodes, and in 
particular the common case where number of partitions = number of nodes.
   
   We assume we start from a pretty balanced assignment (all processes have 
roughly equal load). Then, the assignment by-load below is mostly a round-robin 
assignment in most situations:
   
    - If we start fresh, all processes have 0 load and we will do a complete 
round-robin assignment
    - If we scale down, all processes will have roughly the same N load and we 
will do roughly round-robin assignment
    - If we scale up, we will assign all the tasks that we didnt assign above 
to the new nodes. We will do a round-robin assignment among the new nodes.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to