Skip to content

[Serve] Mark per-deployment autoscaling metrics push interval config deprecated#55102

Merged
zcin merged 11 commits intoray-project:masterfrom
JoshKarpel:announce-deprecations-for-amortized-metrics-pushing
Aug 7, 2025
Merged

[Serve] Mark per-deployment autoscaling metrics push interval config deprecated#55102
zcin merged 11 commits intoray-project:masterfrom
JoshKarpel:announce-deprecations-for-amortized-metrics-pushing

Conversation

@JoshKarpel
Copy link
Copy Markdown
Contributor

@JoshKarpel JoshKarpel commented Jul 31, 2025

Why are these changes needed?

Deprecation announcements for this future PR #55016

Related issue number

Related to #45777

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Josh Karpel <josh.karpel@gmail.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @JoshKarpel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request is a preparatory step for future changes in Ray Serve's autoscaling configuration. It deprecates the existing metrics_interval_s field in AutoscalingConfig and introduces new, more specific environment variables for controlling autoscaling metric push and record intervals. This change aims to provide more explicit and granular control over these critical timing parameters.

Highlights

  • Deprecation of metrics_interval_s: The metrics_interval_s field within Ray Serve's AutoscalingConfig (in both Python and its protobuf definition) has been marked as deprecated. This signals a shift towards environment variable-based configuration for autoscaling metric push intervals.
  • Introduction of New Environment Variable-backed Constants: New constants backed by environment variables have been introduced in python/ray/serve/_private/constants.py to provide more granular control over autoscaling metric push intervals. These include RAY_SERVE_REPLICA_AUTOSCALING_METRIC_PUSH_INTERVAL_S and RAY_SERVE_HANDLE_AUTOSCALING_METRIC_PUSH_INTERVAL_S.
  • Renaming and Externalizing Record Intervals: Existing internal constants for autoscaling metric record periods (e.g., RAY_SERVE_REPLICA_AUTOSCALING_METRIC_RECORD_PERIOD_S) have been renamed to use _INTERVAL_S (e.g., RAY_SERVE_REPLICA_AUTOSCALING_METRIC_RECORD_INTERVAL_S) and are now configurable via environment variables.
  • Internal Code Migration: Internal code in python/ray/serve/_private/replica.py and python/ray/serve/_private/router.py has been updated to utilize the newly introduced or renamed constants for autoscaling metric recording and pushing, ensuring consistency with the new configuration approach.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively deprecates the per-deployment autoscaling metrics push interval configuration, replacing it with new environment variables. The changes are consistent across the codebase, including updates to configurations, constants, and documentation. I have suggestions to improve the clarity and correctness of the fallback logic for the new environment variables in python/ray/serve/_private/constants.py and to update the deprecated comments in python/ray/serve/config.py and src/ray/protobuf/serve.proto.

Signed-off-by: Josh Karpel <josh.karpel@gmail.com>
Signed-off-by: Josh Karpel <josh.karpel@gmail.com>
@JoshKarpel JoshKarpel marked this pull request as ready for review July 31, 2025 19:18
@JoshKarpel JoshKarpel requested a review from a team as a code owner July 31, 2025 19:18
@JoshKarpel
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request deprecates the metrics_interval_s configuration, introduces new environment variables for configuring autoscaling metric push intervals, and provides backward compatibility for the legacy environment variable. The deprecation is communicated through code comments, docstrings, and a DeprecationWarning. The tests have been updated to reflect these changes. I've provided suggestions to enhance code readability.

@ray-gardener ray-gardener bot added community-contribution Contributed by the community serve Ray Serve Related Issue docs An issue or change related to documentation deprecation Scheduled for deprecation labels Aug 1, 2025
@JoshKarpel JoshKarpel requested a review from a team as a code owner August 1, 2025 14:26
Signed-off-by: Josh Karpel <josh.karpel@gmail.com>
return max_replicas

@validator("metrics_interval_s")
def metrics_interval_s_deprecation_warning(cls, v: PositiveFloat) -> PositiveFloat:
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.

@JoshKarpel do you know if users use serve.deployment(autoscaling_config={"metrics_interval_s": 10}) without using the AutoscalingConfig directly, will this print the warning? And also if they set it in a serve config and deploy it, will it print in controller logs?

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.

Ah, good question, let me give that a try

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.

Added these cases to the test! They do indeed raise the warning in both of those situations.

Signed-off-by: Josh Karpel <josh.karpel@gmail.com>
Copy link
Copy Markdown
Contributor

@zcin zcin left a comment

Choose a reason for hiding this comment

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

looks good!

@zcin zcin added the go add ONLY when ready to merge, run all tests label Aug 6, 2025
@zcin zcin enabled auto-merge (squash) August 6, 2025 23:28
@zcin zcin merged commit 60d6d2d into ray-project:master Aug 7, 2025
7 checks passed
@JoshKarpel JoshKarpel deleted the announce-deprecations-for-amortized-metrics-pushing branch August 7, 2025 01:03
@JoshKarpel
Copy link
Copy Markdown
Contributor Author

Thanks @zcin !

sampan-s-nayak pushed a commit that referenced this pull request Aug 12, 2025
…deprecated (#55102)

## Why are these changes needed?

Deprecation announcements for this future PR
#55016

## Related issue number

Related to #45777

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

---------

Signed-off-by: Josh Karpel <josh.karpel@gmail.com>
Signed-off-by: sampan <sampan@anyscale.com>
dioptre pushed a commit to sourcetable/ray that referenced this pull request Aug 20, 2025
…deprecated (ray-project#55102)

## Why are these changes needed?

Deprecation announcements for this future PR
ray-project#55016

## Related issue number

Related to ray-project#45777

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

---------

Signed-off-by: Josh Karpel <josh.karpel@gmail.com>
Signed-off-by: Andrew Grosser <dioptre@gmail.com>
jugalshah291 pushed a commit to jugalshah291/ray_fork that referenced this pull request Sep 11, 2025
…deprecated (ray-project#55102)

## Why are these changes needed?

Deprecation announcements for this future PR
ray-project#55016

## Related issue number

Related to ray-project#45777

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

---------

Signed-off-by: Josh Karpel <josh.karpel@gmail.com>
Signed-off-by: jugalshah291 <shah.jugal291@gmail.com>
dstrodtman pushed a commit that referenced this pull request Oct 6, 2025
…deprecated (#55102)

## Why are these changes needed?

Deprecation announcements for this future PR
#55016

## Related issue number

Related to #45777

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

---------

Signed-off-by: Josh Karpel <josh.karpel@gmail.com>
Signed-off-by: Douglas Strodtman <douglas@anyscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community deprecation Scheduled for deprecation docs An issue or change related to documentation go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants