Repository navigation
[Data] Allow Early Resource Release Under Sustained Low Utilization for Rate-based Cluster Autoscaler - #66584
Conversation
Signed-off-by: Sirui Huang <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a bounded grace window to the rate-based cluster autoscaler. When cluster utilization drops below the scale-up threshold, the last explicit resource request is kept alive briefly before releasing it with an empty request, allowing idle termination to reclaim nodes. Unit tests have been added to verify this grace period and release behavior. Feedback on the changes suggests avoiding the reassignment of the resource_request parameter in _send_resource_request by using a local variable instead, which improves code readability and maintainability.
| now = self._get_time() | ||
| update_non_empty_request_state = True | ||
| if resource_request is None: | ||
| if self._should_keep_non_empty_request(now): | ||
| resource_request = self._last_non_empty_resource_request | ||
| update_non_empty_request_state = False | ||
| else: | ||
| # Renew our registration on AutoscalingCoordinator without | ||
| # keeping explicit autoscaler demand alive. | ||
| resource_request = [] | ||
|
|
||
| self._last_resource_request = [r.copy() for r in resource_request] | ||
| self._autoscaling_coordinator.request_resources( | ||
| resources=[r.copy() for r in resource_request], | ||
| expire_after_s=self._autoscaling_request_expire_time_s, | ||
| request_remaining=STANDARD_RESOURCE_TYPES, | ||
| ) | ||
| self._last_request_time = time.monotonic() | ||
| if resource_request and update_non_empty_request_state: | ||
| self._last_non_empty_resource_request = [ | ||
| bundle.copy() for bundle in resource_request | ||
| ] | ||
| self._last_non_empty_request_time = now | ||
| elif not resource_request: | ||
| self._last_non_empty_resource_request = [] | ||
| self._last_non_empty_request_time = None | ||
| self._last_request_time = now |
There was a problem hiding this comment.
Reassigning the parameter resource_request can make the code harder to read and maintain, as it obscures the original input value and changes the variable's meaning mid-execution. It is cleaner and less error-prone to use a local variable (e.g., resolved_request) to hold the final request list that is actually sent.
now = self._get_time()
update_non_empty_request_state = True
if resource_request is None:
if self._should_keep_non_empty_request(now):
resolved_request = self._last_non_empty_resource_request
update_non_empty_request_state = False
else:
# Renew our registration on AutoscalingCoordinator without
# keeping explicit autoscaler demand alive.
resolved_request = []
else:
resolved_request = resource_request
self._last_resource_request = [r.copy() for r in resolved_request]
self._autoscaling_coordinator.request_resources(
resources=[r.copy() for r in resolved_request],
expire_after_s=self._autoscaling_request_expire_time_s,
request_remaining=STANDARD_RESOURCE_TYPES,
)
if resolved_request and update_non_empty_request_state:
self._last_non_empty_resource_request = [
bundle.copy() for bundle in resolved_request
]
self._last_non_empty_request_time = now
elif not resolved_request:
self._last_non_empty_resource_request = []
self._last_non_empty_request_time = None
self._last_request_time = nowThere was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation matches the described V2 semantics and includes focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Adds bounded release of explicit resource demand to the rate-based Ray Data cluster autoscaler during sustained low utilization.
Changes:
- Reuses
RAY_DATA_LOW_UTIL_REQUEST_RELEASE_DELAY_Swith a 180-second default. - Tracks the last non-empty request and releases it after the grace period while preserving requester registration.
- Adds unit coverage and updates E2E request recording for keep-alive calls.
| File | Description |
|---|---|
python/ray/data/_internal/cluster_autoscaler/rate_based_cluster_autoscaler.py |
Implements low-utilization request retention and release. |
python/ray/data/tests/test_rate_based_cluster_autoscaler.py |
Tests grace-period retention, release, and re-arming. |
python/ray/data/tests/test_rate_based_cluster_autoscaler_e2e.py |
Records None keep-alive requests in E2E tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…or Rate-based Cluster Autoscaler (ray-project#66584) ## Description `DefaultClusterAutoscalerV2` releases its resource request under sustained low utilization (for example a straggler tail), so idle nodes can be reclaimed. The rate-based cluster autoscaler lacks this and keeps re-sending its last request indefinitely, pinning nodes that nothing is using. This PR strengthens the rate-based cluster autoscaler implementation by adding the same mechanism. On low utilization the autoscaler keeps its last non-empty request alive only for a grace window measured from when that request was sent (`RAY_DATA_LOW_UTIL_REQUEST_RELEASE_DELAY_S`, default 180s), then sends an empty request that keeps the requester registered but drops the demand. It reuses V2's environment variable and field names. ## Related issues Related to ray-project#62592, which added this to `DefaultClusterAutoscalerV2`. Adding feature to ray-project#65954. ## Additional information Also includes unit tests for examining whether the mechanism is behaving correctly. Not a duplicate: no open PR touches rate-based low-utilization release. Signed-off-by: Sirui Huang <[email protected]>
Description
DefaultClusterAutoscalerV2releases its resource request under sustained low utilization (for example a straggler tail), so idle nodes can be reclaimed. The rate-based cluster autoscaler lacks this and keeps re-sending its last requestindefinitely, pinning nodes that nothing is using.
This PR strengthens the rate-based cluster autoscaler implementation by adding the same mechanism. On low utilization the autoscaler keeps its last non-empty request alive only for a grace window measured from when that request was sent (
RAY_DATA_LOW_UTIL_REQUEST_RELEASE_DELAY_S, default 180s), then sends an empty request that keeps the requester registered but drops the demand. It reuses V2's environment variable and field names.Related issues
Related to #62592, which added this to
DefaultClusterAutoscalerV2. Adding feature to #65954.Additional information
Also includes unit tests for examining whether the mechanism is behaving correctly. Not a duplicate: no open PR touches rate-based low-utilization release.