Skip to content

KAFKA-12495: Improve rebalance allocation algorithm#1

Merged
vamossagar12 merged 3 commits into
vamossagar12:KAFKA-12495from
C0urante:kafka-12495-followup
Nov 15, 2022
Merged

KAFKA-12495: Improve rebalance allocation algorithm#1
vamossagar12 merged 3 commits into
vamossagar12:KAFKA-12495from
C0urante:kafka-12495-followup

Conversation

@C0urante

@C0urante C0urante commented Oct 23, 2022

Copy link
Copy Markdown

Follow-up as discussed on the open PR for KAFKA-12495, which ports some changes from apache#12019 onto that PR branch.

These changes should fix some issues with load-balancing revocations and assignment of new and lost connectors and tasks. The primary differences are when load-balancing revocations take place (a number of currently-missed cases are added), when lost assignments are reassigned, and how load-balancing revocations are calculated.

One result is that a number of unnecessary follow-up rebalances are skipped since a balanced allocation can be achieved sooner, and potential regressions introduced in the upstream PR for KAFKA-12495 are avoided as a result.

Another result is that resizing connectors should no longer lead to unbalanced allocations across the cluster during rebalance.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@C0urante

Copy link
Copy Markdown
Author

This is ready for review now, but I've marked it as a draft to signal that it should not be merged into the upstream branch yet. I'm hoping we can review this PR separately until it's approved to be merged into the trunk branch of the upstream repo, then merge it and the upstream KAFKA-12495 branch together into trunk all at once.

@vamossagar12 vamossagar12 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@C0urante , Thanks for the follow up PR! I have a few comments mainly for my understanding and some naming related stuffs which I felt could change

@C0urante C0urante left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vamossagar12, this is ready for another round when you have time. I've also removed some now-unused methods, as a minor cleanup step.

@vamossagar12

vamossagar12 commented Oct 27, 2022

Copy link
Copy Markdown
Owner

Thanks @vamossagar12, this is ready for another round when you have time. I've also removed some now-unused methods, as a minor cleanup step.

Thanks @C0urante . I made another pass.

@C0urante

C0urante commented Nov 1, 2022

Copy link
Copy Markdown
Author

Thanks @vamossagar12. Ready for the next round when you have time.

@vamossagar12

Copy link
Copy Markdown
Owner

@C0urante , I looked at it again. The changes look good to me and can't think of new comments at this point. Thanks for the changes !

@C0urante

C0urante commented Nov 2, 2022

Copy link
Copy Markdown
Author

Thanks @vamossagar12!

@showuon if you can spare a few cycles, mind taking a look? Once this is ready to go we should be able to finally merge a fix for KAFKA-12495!

@showuon

showuon commented Nov 11, 2022

Copy link
Copy Markdown

Sorry, quite busy these days. I'll try to review it next week.

@showuon showuon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@C0urante , thanks for the improvement. Overall LGTM! Just some minor comments.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add a comment above this for loop to mention we're going to calculate how many connectors/tasks to revoke from existing worker

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Done

Comment on lines 445 to 502

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changed to 0 delay now?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to optimizations in the allocation algorithm, we no longer perform a task-balancing revocation in the fourth round, which allows us to reset the delay.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

Comment on lines 1092 to 1097

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement

Comment on lines 520 to 526

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to confirm if we don't have this patch, this test will fail in apache#12561 , right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct 👍

Comment on lines 259 to 260

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have preference here, but we changed the variable name from newSubmissions to created, should we also update the comment?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good call, done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment:
Any workers that left the group within the scheduled rebalance delay permanently left the group.
The word permanently seems to be confusing to me.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, the javadoc can be more clear if we remove all these 3 bullets, because I felt more confused after reading these 3 bullets. So, maybe change to:
Revoke connectors and tasks from each worker in the cluster until no worker is running more than it would be

WDYT?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with simplifying this 👍
I updated it to Revoke connectors and tasks from each worker in the cluster until no worker is running more than it would be with a perfectly-balanced assignment.; LMKWYT

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@C0urante

C0urante commented Nov 14, 2022

Copy link
Copy Markdown
Author

Thanks @showuon! Pushed a new commit; ready when you have time.

@showuon showuon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great improvement!

@vamossagar12

vamossagar12 commented Nov 15, 2022

Copy link
Copy Markdown
Owner

Thanks for your time @showuon ! @C0urante , how do we want to take this further? Merge this into my branch and merge that or you want to create another PR against trunk and merge the 2 of them together? I guess it would be better to do the latter to highlight the great improvements you have made here (former might be simpler I reckon)

@showuon

showuon commented Nov 15, 2022

Copy link
Copy Markdown

Merge it into this branch, and check the jenkins build status

@vamossagar12

Copy link
Copy Markdown
Owner

@showuon , Chris had a different idea I think =>

This is ready for review now, but I've marked it as a draft to signal that it should not be merged into the upstream branch yet. I'm hoping we can review this PR separately until it's approved to be merged into the trunk branch of the upstream repo, then merge it and the upstream KAFKA-12495 branch together into trunk all at once.

Would wait for his response.

@C0urante
C0urante marked this pull request as ready for review November 15, 2022 16:00
@C0urante

Copy link
Copy Markdown
Author

@vamossagar12 it's fine to merge this one now :)

@vamossagar12 vamossagar12 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@C0urante
C0urante force-pushed the kafka-12495-followup branch from b4fb6fc to 3eb5e13 Compare November 15, 2022 16:09
@vamossagar12
vamossagar12 merged commit 422c81f into vamossagar12:KAFKA-12495 Nov 15, 2022
@C0urante
C0urante deleted the kafka-12495-followup branch November 15, 2022 16:11
@vamossagar12

Copy link
Copy Markdown
Owner

@C0urante done! Thanks for your contribution on this one!

@C0urante
C0urante restored the kafka-12495-followup branch November 15, 2022 17:13
@C0urante
C0urante deleted the kafka-12495-followup branch November 15, 2022 17:31
vamossagar12 pushed a commit that referenced this pull request Sep 12, 2023
This change introduces some basic clean up and refactoring for forthcoming commits related to the revised fetch code for the consumer threading refactor project.

Reviewers: Christo Lolov <lolovc@amazon.com>, Jun Rao <junrao@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants