Skip to content

Conversation

@lingyufei
Copy link
Contributor

@lingyufei lingyufei commented Sep 9, 2025

Please refer to issue 15677 for more details.

Although I can now configure tps on a method level, the stats map in DefaultTPSLimiter is still using serviceKey as the key. So the method-level TPS doesn't work. For example, if I configure different TPS numbers on different methods, they are actually sharing the same StatItem, which is obtained by the service key.

Here is what I have done:

  1. The key of StatItem Map should be serviceKey + method if the tps is configured for a method. Otherwise, uses serviceKey. TPS for a method has a higher priority than for a service.
  2. Add tests for method-level tps precedence and isolation.

@lingyufei lingyufei changed the title [ISSUE 15677] Support method level tps limiter [ISSUE 15677] Support method level DefaultTPSLimiter Sep 9, 2025
@lingyufei lingyufei changed the title [ISSUE 15677] Support method level DefaultTPSLimiter [ISSUE 15677] Support method level in DefaultTPSLimiter Sep 9, 2025
@lingyufei lingyufei changed the title [ISSUE 15677] Support method level in DefaultTPSLimiter [ISSUE 15677] Support method level TPS in DefaultTPSLimiter Sep 9, 2025
@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.02%. Comparing base (d45ce97) to head (e10b010).

Files with missing lines Patch % Lines
...apache/dubbo/rpc/filter/tps/DefaultTPSLimiter.java 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##                3.3   #15679   +/-   ##
=========================================
  Coverage     61.01%   61.02%           
+ Complexity    11698    11697    -1     
=========================================
  Files          1923     1923           
  Lines         87069    87073    +4     
  Branches      13112    13113    +1     
=========================================
+ Hits          53124    53134   +10     
+ Misses        28495    28490    -5     
+ Partials       5450     5449    -1     
Flag Coverage Δ
integration-tests-java21 32.90% <0.00%> (+<0.01%) ⬆️
integration-tests-java8 33.01% <0.00%> (+0.05%) ⬆️
samples-tests-java21 32.66% <0.00%> (+<0.01%) ⬆️
samples-tests-java8 30.34% <0.00%> (+0.05%) ⬆️
unit-tests-java11 59.00% <83.33%> (-0.01%) ⬇️
unit-tests-java17 58.75% <83.33%> (-0.01%) ⬇️
unit-tests-java21 58.76% <83.33%> (+0.01%) ⬆️
unit-tests-java8 59.02% <83.33%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zrlw zrlw requested a review from Copilot September 10, 2025 01:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements method-level TPS (Transactions Per Second) limiting in DefaultTPSLimiter by modifying the key generation strategy for the internal statistics map. Previously, method-level TPS configurations were ignored because all methods of a service shared the same StatItem using only the service key.

  • Modified key generation to include method name when method-level TPS is configured
  • Added method-level TPS precedence logic to prioritize method configuration over service configuration
  • Added comprehensive tests to verify method-level TPS isolation and precedence behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
DefaultTPSLimiter.java Updated key generation logic to support method-level TPS by appending method name to service key when method-level configuration exists
DefaultTPSLimiterTest.java Added three new test methods to verify method-level TPS precedence, service-level fallback, and isolation between methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +44 to +46
String key = isMethodLevelTpsConfigured
? url.getServiceKey() + "#" + RpcUtils.getMethodName(invocation)
: url.getServiceKey();
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

[nitpick] The hardcoded '#' separator could be extracted as a constant to improve maintainability and make the key format more explicit.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn’t support method overloading here, but that should be fine.

Copy link
Contributor

@zrlw zrlw left a comment

Choose a reason for hiding this comment

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

LGTM

@lingyufei
Copy link
Contributor Author

lingyufei commented Sep 16, 2025

Is there any update on this? Please let me know if you have any questions about this.

@zrlw zrlw requested a review from oxsean September 18, 2025 06:05
Copy link
Contributor

@oxsean oxsean left a comment

Choose a reason for hiding this comment

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

LGTM.

@zrlw zrlw merged commit bc543b6 into apache:3.3 Sep 18, 2025
32 checks passed
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.

4 participants