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

feature: add single server rale limit #6756

Open
wants to merge 18 commits into
base: 2.x
Choose a base branch
from

Conversation

xjlgod
Copy link
Contributor

@xjlgod xjlgod commented Aug 14, 2024

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Support flow limiting control for a single server:

  • Flow limiting components: Select Bucket4j components to implement flow limit control.
  • Processing flow limit control: Process flow limiting at the top level in DefaultCordinator, and perform flow limiting checks in the onRequest method. Only GlobalBegin request will be limited.
  • Transaction end identity: All transaction ends need to be able to correctly identify flow limit control and throw corresponding exceptions.
  • Metrics: Use a new metrics record events when current limiting is triggered

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Copy link

codecov bot commented Aug 24, 2024

Codecov Report

Attention: Patch coverage is 46.74556% with 90 lines in your changes missing coverage. Please review.

Project coverage is 52.59%. Comparing base (dbe095a) to head (aa37e27).

Files with missing lines Patch % Lines
...va/org/apache/seata/core/event/RateLimitEvent.java 0.00% 23 Missing ⚠️
...che/seata/server/ratelimit/TokenBucketLimiter.java 45.71% 19 Missing ⚠️
...e/properties/server/ServerRateLimitProperties.java 7.69% 12 Missing ⚠️
...e/seata/server/coordinator/DefaultCoordinator.java 9.09% 9 Missing and 1 partial ⚠️
...che/seata/server/ratelimit/RateLimiterHandler.java 56.52% 9 Missing and 1 partial ⚠️
...handler/GlobalTransactionalInterceptorHandler.java 0.00% 3 Missing ⚠️
...ava/io/seata/tm/api/DefaultFailureHandlerImpl.java 0.00% 2 Missing ⚠️
...ga/engine/tm/DefaultSagaTransactionalTemplate.java 0.00% 2 Missing ⚠️
...zer/seata/protocol/AbstractResultMessageCodec.java 0.00% 0 Missing and 2 partials ⚠️
...org/apache/seata/tm/DefaultTransactionManager.java 0.00% 2 Missing ⚠️
... and 3 more
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6756      +/-   ##
============================================
- Coverage     52.61%   52.59%   -0.03%     
- Complexity     6579     6602      +23     
============================================
  Files          1126     1131       +5     
  Lines         39928    40093     +165     
  Branches       4680     4695      +15     
============================================
+ Hits          21010    21087      +77     
- Misses        16916    17001      +85     
- Partials       2002     2005       +3     
Files with missing lines Coverage Δ
...ava/org/apache/seata/common/ConfigurationKeys.java 0.00% <ø> (ø)
...seata/core/exception/TransactionExceptionCode.java 100.00% <100.00%> (ø)
...ava/org/apache/seata/core/protocol/ResultCode.java 100.00% <100.00%> (ø)
...ta/spring/boot/autoconfigure/StarterConstants.java 100.00% <ø> (ø)
.../apache/seata/server/metrics/MeterIdConstants.java 100.00% <100.00%> (ø)
.../apache/seata/server/metrics/MetricsPublisher.java 94.73% <100.00%> (+0.98%) ⬆️
...apache/seata/server/metrics/MetricsSubscriber.java 77.14% <100.00%> (+2.67%) ⬆️
...g/apache/seata/server/ratelimit/RateLimitInfo.java 100.00% <100.00%> (ø)
...org/apache/seata/tm/api/TransactionalExecutor.java 65.51% <100.00%> (+1.23%) ⬆️
...configure/SeataServerEnvironmentPostProcessor.java 0.00% <0.00%> (ø)
... and 12 more

... and 2 files with indirect coverage changes

@slievrly slievrly self-requested a review August 31, 2024 14:51
@slievrly slievrly added this to the 2.3.0 milestone Aug 31, 2024
@funky-eyes funky-eyes added type: feature Category issues or prs related to feature request. module/server server module labels Sep 3, 2024
/**
* The constant RATE_LIMIT_BUCKET_TOKEN_SECOND_NUM.
*/
String RATE_LIMIT_BUCKET_TOKEN_SECOND_NUM = RATE_LIMIT_PREFIX + "bucketTokenSecondNum";
Copy link
Contributor

Choose a reason for hiding this comment

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

bucketTokenNumPerSecond

Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

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

The rate limit has to immediate effect when it enable or change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/server server module type: feature Category issues or prs related to feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants