-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[grid] Add GreedySlotSelector as a built-in slot-selector option #15897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new built-in greedy slot selector to enhance node utilization in the Selenium Grid by prioritizing partially filled nodes using a multi-criteria sorting approach.
- Added GreedySlotSelector that implements a SlotSelector interface with a chain of comparators based on node utilization, slot count, load, session creation time, browser version, and node ID.
- Provided comprehensive tests to validate the behavior of node selection and load balancing.
java/src/org/openqa/selenium/grid/distributor/selector/GreedySlotSelector.java
Outdated
Show resolved
Hide resolved
java/src/org/openqa/selenium/grid/distributor/selector/GreedySlotSelector.java
Outdated
Show resolved
Hide resolved
PR Code Suggestions ✨Explore these optional code suggestions:
|
CI Feedback 🧐(Feedback updated until commit fd27a60)A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
Signed-off-by: Viet Nguyen Duc <[email protected]>
71a813e
to
9f5ff01
Compare
User description
🔗 Related Issues
💥 What does this PR do?
Fixes #15870
This is good for autoscaling (with max sessions > 1 per node), where all available slots in a Node will be utilized fully before assigning a session to another new Node.
Session assign with GreedySlotSelector strategy
GreedySlotSelector.mp4
Look back the session assign with DefaultSlotSelector
DefaultSlotSelector.mp4
Usage: pass value to CLI option
--slot-selector
when starting Distributor (or Hub/Standalone), or similar in TOML configFor example:
--slot-selector org.openqa.selenium.grid.distributor.selector.GreedySlotSelector
How it works in the background
A greedy slot selector that aims to maximize node utilization by minimizing the number of partially filled nodes. The algorithm works as follows:
This approach helps to:
🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement
Description
• Add GreedySlotSelector for maximizing node utilization in Grid
• Implements greedy algorithm prioritizing partially filled nodes
• Includes comprehensive test suite with 429 test lines
• Configurable via CLI --slot-matcher option
Changes walkthrough 📝
GreedySlotSelector.java
New GreedySlotSelector implementation
java/src/org/openqa/selenium/grid/distributor/selector/GreedySlotSelector.java
• Implements SlotSelector interface with greedy algorithm
•
Prioritizes nodes by utilization ratio (descending order)
• Falls back
to total slots, load, and browser version for tie-breaking
• Includes
factory method for configuration integration
GreedySlotSelectorTest.java
Complete test coverage for GreedySlotSelector
java/test/org/openqa/selenium/grid/distributor/selector/GreedySlotSelectorTest.java
• Comprehensive test suite with 11 test methods
• Tests utilization
prioritization over capability matching
• Validates node selection
ordering and load balancing
• Includes helper methods for creating
test nodes