Repository navigation
[cherry-pick][2.60.0][serve][in-place-updates][4/n] Add max_surge_percent for start-before-stop rolling updates (#66267) - #67094
Conversation
…re-stop rolling updates (ray-project#66267) Draft for discussion of the rollout behavior raised in ray-project#63016. Rolling updates currently stop old replicas before starting replacements, temporarily reducing capacity. This adds `max_surge_percent` to start replacements first. Old replicas stop in batches once enough replacements are running to maintain the target count. If capacity is unavailable, replacements wait while old replicas keep serving. The default is `0`, preserving existing behavior. Gang deployments round the allowance up to whole gangs. During a terminally failed surge update, reducing the replica count is deferred until a deploy changes the target. <img width="1497" height="1185" alt="image" src="https://github.com/user-attachments/assets/d4d6dcbb-c93a-4a35-87c9-fb9fbf491a98" /> Example usage: in YAML ``` name: surge-demo image_uri: anyscale/ray:nightly-py311 # needs a Ray with ray-project#66267 working_dir: . applications: - name: app import_path: serve_app:app deployments: - name: Model num_replicas: 4 max_surge_percent: 50 # up to 2 extra replicas during a restart graceful_shutdown_timeout_s: 60 ``` or via decorator: ``` from ray import serve from starlette.requests import Request @serve.deployment(num_replicas=4, max_surge_percent=50) class Model: def __init__(self, version: str = "v1"): self.version = version async def __call__(self, request: Request) -> str: return f"hello from {self.version}" app = Model.bind() ``` Added end-to-end tests covering surge rolling updates: - Startup failures, rollback reusing original replicas, and successful surge replacement while preserving capacity and serving traffic, with and without a controller restart. - Independent surge rollouts and rollbacks across multiple applications. - Surge with autoscaling, graceful request draining, scale-to-zero, and recovery after a failed deployment. - Whole-gang surge replacement, failure handling, and rollback. - Replica-count increases and decreases during surge rollouts. - Health-check failures stopping a surge rollout, followed by rollback preserving surviving old replicas. - Insufficient capacity leaving surge replacements pending while old replicas keep serving. ```text python -m pytest python/ray/serve/tests/unit/test_deployment_state.py python/ray/serve/tests/unit/test_config.py python/ray/serve/tests/unit/test_deployment_class.py python -m pytest python/ray/serve/tests/test_deploy_app_2.py -k surge_rolling_update ``` Duplicate checks found no overlapping implementation. Claude Code assisted with implementation. --------- Signed-off-by: Qisheng He <[email protected]> Signed-off-by: qishengxhe <[email protected]> (cherry picked from commit 9491664) Signed-off-by: qishengxhe <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces the max_surge_percent configuration option for Ray Serve deployments, allowing extra replicas to be started during a rolling update before old replicas are stopped. This ensures that capacity is maintained and traffic is served continuously during updates. The changes include updates to the deployment configuration, state management logic to handle surge rollouts, documentation, and comprehensive unit and integration tests. Since there are no review comments, I have no feedback to provide.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 947e832. Configure here.
|
|
||
| // Extra replicas allowed during a rolling restart, as a percentage of the | ||
| // target count. Defaults to 0, which stops old replicas before starting new ones. | ||
| int32 max_surge_percent = 25; |
There was a problem hiding this comment.
Proto change needs fault-tolerance review
Low Severity
.proto files.
Please review the RPC fault-tolerance & idempotency standards guide here:
https://github.com/ray-project/ray/tree/master/doc/source/ray-core/internals/rpc-fault-tolerance.rst
Triggered by project rule: Bugbot Rules
Reviewed by Cursor Bugbot for commit 947e832. Configure here.
77010ab
into
ray-project:releases/2.60.0


Cherry-pick of #66267 (master commit 9491664) onto
releases/2.60.0.Why
The first three PRs of the in-place-updates series (#66252, #66290, #66266) are already on
releases/2.60.0. This picks the fourth, which addsmax_surge_percentfor start-before-stop rolling updates, so 2.60.0 ships the complete series.Cherry-pick details
git cherry-pick -xconflicted in one file,python/ray/serve/tests/unit/test_deployment_state.py. The conflict was positional only: on master, #66243 (push-based replica health) had appendedTestPushedHealthEndToEndand related tests to the end of that file, and #66267 insertsTestMaxSurgeright before them. This branch doesn't have #66243, so git couldn't anchor the hunk and offered the #66243 tests as part of the incoming side. Resolved by inserting only the PR'sTestMaxSurgeblock (plus itsdefaultdictimport) before the__main__guard. The added and removed lines in each of the 17 files are identical to the master commit's diff.After the pick, 11 of the 17 files are byte-identical to master at 9491664. The other 6 differ only by master commits that aren't on this branch and that #66267 doesn't depend on:
_private/deployment_state.py,tests/unit/test_deployment_state.py: [serve] Push-based replica health: controller-side receive path #66243.schema.py,tests/BUILD.bazel,tests/test_controller.py,tests/test_direct_ingress.py: [serve][llm] Fall back to available replicas when ingress routers fail #66339 and [serve] Deflake test_direct_ingress by moving the test gRPC port range below the ephemeral range #66940.No commit on
releases/2.60.0after the branch cut touched any of these files.Not a duplicate: no PR against
releases/2.60.0references #66267.Testing
Run on this branch with the Serve protobuf regenerated from the branch's
serve.proto(the pick adds themax_surge_percentfield).pre-commit run --files <changed files>passed.AI assistance was used to prepare this cherry-pick.
🤖 Generated with Claude Code