Skip to content

[serve] don't stop retrying replicas when a deployment is scaling back up from zero - #51600

Merged
zcin merged 7 commits into
ray-project:masterfrom
zcin:autoscale_unhealthy
Mar 24, 2025
Merged

zcin merged 7 commits into
ray-project:masterfrom
zcin:autoscale_unhealthy

Conversation

@zcin

@zcin zcin commented Mar 21, 2025 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Previously we added a new deployment status DEPLOY_FAILED, which a deployment transitions into if the replicas repeatedly fail to start after a new config update / new deployment. After a certain number of retries, the controller will stop retrying replicas for that deployment and it enters a terminal state. However that causes deployments whose replicas fail during autoscaling (from zero) to also stop retrying after the threshold. This PR fixes that.

Summary of failure scenarios and how we now handle them:

  1. A deployment is first deployed / re-deployed. If the number of replica failures exceed a threshold (3 * target), and not a single replica was able to start successfully, the deployment transitions to DEPLOY_FAILED and no more replicas are retried. This state is terminal, and user must redeploy.
  2. An autoscaling deployment is deployed with initial_replicas = 0. A request is sent and replicas fail to start. Similarly if the number of replica failures exceed a threshold (3 * target), and not a single replica was able to start successfully, no more replicas are retried. The deployment transitions to UNHEALTHY.
  3. An autoscaling deployment is deployed and replicas start successfully. It later scales down and tries to scale back up again, but there are a lot of replica failures. Here the deployment could transition to UNHEALTHY if there are enough replica failures, but replicas will continue to retry.

Related issue number

closes #50710

zcin added 2 commits March 21, 2025 11:56
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
@zcin
zcin marked this pull request as ready for review March 21, 2025 22:15
@zcin zcin added the go add ONLY when ready to merge, run all tests label Mar 21, 2025

@akyang-anyscale akyang-anyscale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some nits, but lgtm

self._replica_constructor_retry_counter += 1
self._replica_constructor_error_msg = error_msg

# Update the deployment message only if replicas are failing during

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the case the deployment has started a replica successfully, we still might want to show the "Retrying" message if a future replica is struggling to start up. We can just omit the # of times since it will retry indefinitely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

zcin added 5 commits March 21, 2025 16:26
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
@zcin
zcin merged commit 35d472a into ray-project:master Mar 24, 2025
@zcin
zcin deleted the autoscale_unhealthy branch March 24, 2025 16:21
dhakshin32 pushed a commit to dhakshin32/ray that referenced this pull request Mar 27, 2025
…k up from zero (ray-project#51600)

## Why are these changes needed?

Previously we added a new deployment status `DEPLOY_FAILED`, which a
deployment transitions into if the replicas repeatedly fail to start
after a new config update / new deployment. After a certain number of
retries, the controller will stop retrying replicas for that deployment
and it enters a terminal state. However that causes deployments whose
replicas fail during autoscaling (from zero) to also stop retrying after
the threshold. This PR fixes that.

Summary of failure scenarios and how we now handle them:
1. A deployment is first deployed / re-deployed. If the number of
replica failures exceed a threshold (`3 * target`), and not a single
replica was able to start successfully, the deployment transitions to
`DEPLOY_FAILED` and no more replicas are retried. This state is
terminal, and user must redeploy.
2. An autoscaling deployment is deployed with `initial_replicas = 0`. A
request is sent and replicas fail to start. Similarly if the number of
replica failures exceed a threshold (`3 * target`), and not a single
replica was able to start successfully, no more replicas are retried.
The deployment transitions to `UNHEALTHY`.
3. An autoscaling deployment is deployed and replicas start
successfully. It later scales down and tries to scale back up again, but
there are a lot of replica failures. Here the deployment could
transition to `UNHEALTHY` if there are enough replica failures, but
replicas will _continue_ to retry.

## Related issue number

closes ray-project#50710

---------

Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Dhakshin Suriakannu <[email protected]>
srinathk10 pushed a commit that referenced this pull request Mar 28, 2025
…k up from zero (#51600)

## Why are these changes needed?

Previously we added a new deployment status `DEPLOY_FAILED`, which a
deployment transitions into if the replicas repeatedly fail to start
after a new config update / new deployment. After a certain number of
retries, the controller will stop retrying replicas for that deployment
and it enters a terminal state. However that causes deployments whose
replicas fail during autoscaling (from zero) to also stop retrying after
the threshold. This PR fixes that.

Summary of failure scenarios and how we now handle them:
1. A deployment is first deployed / re-deployed. If the number of
replica failures exceed a threshold (`3 * target`), and not a single
replica was able to start successfully, the deployment transitions to
`DEPLOY_FAILED` and no more replicas are retried. This state is
terminal, and user must redeploy.
2. An autoscaling deployment is deployed with `initial_replicas = 0`. A
request is sent and replicas fail to start. Similarly if the number of
replica failures exceed a threshold (`3 * target`), and not a single
replica was able to start successfully, no more replicas are retried.
The deployment transitions to `UNHEALTHY`.
3. An autoscaling deployment is deployed and replicas start
successfully. It later scales down and tries to scale back up again, but
there are a lot of replica failures. Here the deployment could
transition to `UNHEALTHY` if there are enough replica failures, but
replicas will _continue_ to retry.

## Related issue number

closes #50710

---------

Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Srinath Krishnamachari <[email protected]>
qishengxhe added a commit to qishengxhe/ray that referenced this pull request Sep 18, 2026
…update

`is_available` was derived from `_terminally_failed()` alone, so once a
rolling update hit the replica startup threshold the routers rejected every
request (HTTP 503) although the old-version replicas that were not replaced
yet were still RUNNING and in the broadcast running set. A deployment is now
unavailable only when it is terminally failed *and* has no running replica,
which keeps fresh deploys and scale-from-zero (ray-project#51600) unchanged.

Tests: unit test on the broadcast payload after a failed rolling update
(fails on master with is_available=False) and an integration test that keeps
getting 200 from the surviving replica after DEPLOY_FAILED, for both a
rebuild-class and a replica-restart-class update (fails on master with 503).

Signed-off-by: Qisheng He <[email protected]>
qishengxhe added a commit to qishengxhe/ray that referenced this pull request Sep 18, 2026
…update

`is_available` was derived from `_terminally_failed()` alone, so once a
rolling update hit the replica startup threshold the routers rejected every
request (HTTP 503) although the old-version replicas that were not replaced
yet were still RUNNING and in the broadcast running set. A deployment is now
unavailable only when it is terminally failed *and* has no running replica,
which keeps fresh deploys and scale-from-zero (ray-project#51600) unchanged.

Tests: unit test on the broadcast payload after a failed rolling update
(fails on master with is_available=False) and an integration test that keeps
getting 200 from the surviving replica after DEPLOY_FAILED, for both a
rebuild-class and a replica-restart-class update (fails on master with 503).

Signed-off-by: Qisheng He <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-backlog go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Serve] Serve no longer retries deployments after 3 failures

3 participants