Skip to content
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

Gateway plugin report total incoming requests and pending requests #554

Merged
merged 19 commits into from
Jan 21, 2025

Conversation

zhangjyr
Copy link
Collaborator

@zhangjyr zhangjyr commented Jan 8, 2025

Pull Request Description

  1. Upgrade request trace version to 3 that includes two more meta info: "meta_total_reqs" and "meta_pending_reqs."
    While meta_pending_reqs ideally equals pending requests out of the current report window, which is:
meta_pending_reqs = total pending request - current pending requests

The counting of counting requests in the current report window (current pending requests) relies on some kind of request membership in the new created RequestTrace struct, either using term-based or requestID-based. Currently, no request membership is implemented for "current pending requests," so "meta_pending_reqs" is practically smaller than defined.

  1. Improve lock efficiency by (1) Creating a new RequestTrace struct for trace level locking. (2) Minimizing the cache level locking block. (3) Adding test cases to ensure reporting accuracy (no request missing) during trace window transition.

  2. Align the trace report time to the report interval with a max offset of 500ms. Previously, trace reports of tick 30s can be written to the Redis during [30s, 40s) depending on when the gateway plugin starts. This PR fixed this indeterministicity by waiting a short period at the gateway plugin starting. Now, reports will be written to Redis at tick (30s, 30.5s].

  3. Resolved a deadlock problem by calling locked debuginfo() in other locked functions().

  4. Fixed a bug that the gateway plugin can't handle error responses from the vllm and responded with a misunderstanding message.

Related Issues

Resolves: #[Insert issue number(s)]

Important: Before submitting, please complete the description above and review the checklist below.


Contribution Guidelines (Expand for Details)

We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:

Pull Request Title Format

Your PR title should start with one of these prefixes to indicate the nature of the change:

  • [Bug]: Corrections to existing functionality
  • [CI]: Changes to build process or CI pipeline
  • [Docs]: Updates or additions to documentation
  • [API]: Modifications to aibrix's API or interface
  • [CLI]: Changes or additions to the Command Line Interface
  • [Misc]: For changes not covered above (use sparingly)

Note: For changes spanning multiple categories, use multiple prefixes in order of importance.

Submission Checklist

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.

…meta_total_reqs" and "meta_pending_reqs".

Currently, no request membership is implemented for "meta_pending_reqs"
Improve lock efficiency
@zhangjyr zhangjyr requested a review from varungup90 January 9, 2025 19:23
After request returns, request counter now decrease in header phase.
Added benchmark for new approach.
Jingyuan Zhang added 3 commits January 10, 2025 16:57
A request will be counted as completed until all tokens are read, including stream mode.
{\"object\":\"error\",\"message\":\"....\",\"type\":\"BadRequestError\",\"param\":null,\"code\":400}"
@zhangjyr zhangjyr changed the title [WIP] Gateway plugin report total incoming requests and pending requests Gateway plugin report total incoming requests and pending requests Jan 15, 2025
@zhangjyr zhangjyr requested a review from varungup90 January 17, 2025 20:15
@Jeffwan
Copy link
Collaborator

Jeffwan commented Jan 21, 2025

Looks like Varun already approved the change, let's merge this PR.

@Jeffwan Jeffwan merged commit e70ae21 into main Jan 21, 2025
10 checks passed
@Jeffwan Jeffwan deleted the jingyuan/Gateway_plugin_statistics branch January 21, 2025 19:43
gangmuk pushed a commit that referenced this pull request Jan 25, 2025
)

* Upgrade request trace version to 3 that include two more meta info: "meta_total_reqs" and "meta_pending_reqs".
Currently, no request membership is implemented for "meta_pending_reqs"
Improve lock efficiency

* Bug fix: remove deadlocking.

* bug fix

* Improve error logs

* Improve comments

* Pending requests now count total pending only.
After request returns, request counter now decrease in header phase.
Added benchmark for new approach.

* Refine pendingRequests by replace with completionRequests.
A request will be counted as completed until all tokens are read, including stream mode.

* Usage now can correctly handle unknown response, such as:
{\"object\":\"error\",\"message\":\"....\",\"type\":\"BadRequestError\",\"param\":null,\"code\":400}"

* Bug fix, open_ai is IsKnown() function is not applicable in our vLLM

* Update document

* Fix file names and bug fix

* Lint fix

* Update tests

* Update tests

* Temporarily disable a test for further investigation.

* Bug fix

* Rewrite the test to make it more accurate.

* Respond to review comments.

---------

Signed-off-by: Jingyuan <[email protected]>
Co-authored-by: Jingyuan Zhang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants