[Enhancement] Load balancing cache in POP consumption mode #9131
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which Issue(s) This PR Fixes
Add cache for each client request broker end rebalancing in the pop consumption mode to avoid wasting computing resources of broker end due to repeated calculation of load balancing without changes. The effect is more obvious in theory when there are a large number of queues or consumers
Fixes #9123
Brief Description
To add caching for broker-end rebalancing under the pop consumption model, use ReentrantLock to maintain consistency and efficiency. Before performing load balancing calculations, attempt to obtain cache entries when the client list and messagequeue list remain unchanged. Only if the cache is not hit will the calculation logic be executed, using minimal space to avoid wasting broker computing resources and ensuring efficient rebalancing requests
How Did You Test This Change?
Start a name serve, a broker, and two consumer clients locally, using the pop mode for consumption.
Test the performance of broker-side rebalancing with both the original version and the improved version, covering: