-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Serve] create internal request id to track request objects #45761
[Serve] create internal request id to track request objects #45761
Conversation
Signed-off-by: Gene Su <[email protected]>
Signed-off-by: Gene Su <[email protected]>
Signed-off-by: Gene Su <[email protected]>
@@ -396,15 +396,18 @@ def _get_response_handler_info( | |||
if version.parse(starlette.__version__) < version.parse("0.33.0"): | |||
proxy_request.set_path(route_path.replace(route_prefix, "", 1)) | |||
|
|||
internal_request_id = generate_request_id() |
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.
internal_request_id
is generated here always
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.
Thanks for jumping on this so quickly! Much appreciated!
@@ -677,6 +677,7 @@ class DeploymentHandleSource(str, Enum): | |||
@dataclass | |||
class RequestMetadata: | |||
request_id: str | |||
internal_request_id: str |
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.
qq: is the internal_request_id
send as an header to the app behind ray serve proxy? (just a thought)
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.
No it's not, this will appear in the serve context object during the request if there is a need for the deployment to know about it, but the request client won't have this info. Do you think there is a need to pass this back to the client? Can make a new header for it if there is a need for this.
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.
Oh actually reading it again, since it's in the context object, the "app" can get it through calling ray.serve.context._serve_request_context.get(). internal_request_id
. It's not passed as a header to the "app" nor the request "client".
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.
^ not a public API
this internal request ID is purely an implementation detail, shouldn't be exposed to end users
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.
oh ok, let me take it out👍
You got it! Also thanks for the detailed issue, that made writing tests so much easier 😄 |
Signed-off-by: Gene Su <[email protected]>
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.
@GeneDer I believe request_id
is used in some internal data structures inside the replica scheduler logic -- does that part need to be updated?
@@ -677,6 +677,7 @@ class DeploymentHandleSource(str, Enum): | |||
@dataclass | |||
class RequestMetadata: | |||
request_id: str | |||
internal_request_id: str |
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.
^ not a public API
this internal request ID is purely an implementation detail, shouldn't be exposed to end users
Co-authored-by: Edward Oakes <[email protected]> Signed-off-by: Gene Der Su <[email protected]>
Signed-off-by: Gene Su <[email protected]>
I think at a minimum we are using |
Signed-off-by: Gene Su <[email protected]>
Signed-off-by: Gene Su <[email protected]>
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.
LGTM
"""Sending 20 requests in parallel all with the same request id, but with | ||
different request body. | ||
""" | ||
bodies = [{"app_name": f"an_{uuid.uuid4()}"} for _ in range(20)] |
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.
did this fail consistently w/o the code changes?
could do many more concurrent requests here, like 500, to increase confidence
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.
…ect#45761) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? User found an issue where when the request id is reused by multiple requests around the same time, Serve's proxy will be unable to track the request objects correctly. We should not rely on client's request id to be unique during their lifecycle. This PR added a new `internal_request_id` on the `RequestMetadata`, randomly generated by the proxy, to track the request object. Client passed `request_id` continues to be set on the `RequestMetadata` and be used for logging. Also, updated the doc on the request id to make it more clear on what happens when it's re-used. ## Related issue number Closes ray-project#45723 ## 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: Gene Su <[email protected]> Signed-off-by: Gene Der Su <[email protected]> Co-authored-by: Edward Oakes <[email protected]> Signed-off-by: Richard Liu <[email protected]>
Why are these changes needed?
User found an issue where when the request id is reused by multiple requests around the same time, Serve's proxy will be unable to track the request objects correctly. We should not rely on client's request id to be unique during their lifecycle. This PR added a new
internal_request_id
on theRequestMetadata
, randomly generated by the proxy, to track the request object. Client passedrequest_id
continues to be set on theRequestMetadata
and be used for logging. Also, updated the doc on the request id to make it more clear on what happens when it's re-used.Related issue number
Closes #45723
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.