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

feat: add local token cache for cluster #3381

Open
wants to merge 3 commits into
base: 1.8
Choose a base branch
from

Conversation

absolute8511
Copy link

@absolute8511 absolute8511 commented Apr 23, 2024

Change-Id: I6b1ece200cd6b2db181f570ab7207325f12fc12b

Describe what this PR does / why we need it

By default, the cluster limiter will have to request to token server for each request. This will increase the latency and make
too much requests to the token server. In order to solve the performance issue under cluster, the local token cache should be a proposal for this.

Does this pull request fix one issue?

fix #3382

Describe how you did it

In order to reduce the request to server, we add a background prefetch job to period check the tokens and prefetch a batch of tokens if necessary. While the user request coming it will first check the local tokens.

Describe how to verify it

the test case is added to verify it.

Special notes for reviews

@CLAassistant
Copy link

CLAassistant commented Apr 23, 2024

CLA assistant check
All committers have signed the CLA.

Change-Id: I6b1ece200cd6b2db181f570ab7207325f12fc12b
Change-Id: I110062ea817430e8e52779d5c86804f5a476e13f
Change-Id: I86e004d9af1a70011dc9efd630735e4ee9b495e6
Copy link

codecov bot commented May 21, 2024

Codecov Report

Attention: Patch coverage is 64.70588% with 48 lines in your changes are missing coverage. Please review.

Project coverage is 46.36%. Comparing base (cd02b1d) to head (de16134).
Report is 1 commits behind head on 1.8.

Files Patch % Lines
...csp/sentinel/slots/block/flow/FlowRuleChecker.java 0.00% 10 Missing ⚠️
...p/sentinel/slots/statistic/metric/ArrayMetric.java 0.00% 10 Missing ⚠️
...inel/cluster/client/DefaultClusterTokenClient.java 92.47% 4 Missing and 3 partials ⚠️
...a/com/alibaba/csp/sentinel/node/StatisticNode.java 0.00% 6 Missing ⚠️
...p/sentinel/slots/block/flow/ClusterFlowConfig.java 0.00% 4 Missing ⚠️
.../com/alibaba/csp/sentinel/cluster/TokenResult.java 0.00% 3 Missing ⚠️
...ava/com/alibaba/csp/sentinel/node/DefaultNode.java 0.00% 3 Missing ⚠️
...sp/sentinel/slots/statistic/data/MetricBucket.java 0.00% 3 Missing ⚠️
...csp/sentinel/cluster/flow/DefaultTokenService.java 0.00% 1 Missing ⚠️
...nel/cluster/server/DefaultEmbeddedTokenServer.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                1.8    #3381      +/-   ##
============================================
+ Coverage     45.89%   46.36%   +0.46%     
- Complexity     2145     2181      +36     
============================================
  Files           431      431              
  Lines         12903    13039     +136     
  Branches       1727     1749      +22     
============================================
+ Hits           5922     6045     +123     
- Misses         6279     6284       +5     
- Partials        702      710       +8     
Components Coverage Δ
sentinel-adapter 43.22% <ø> (ø)
sentinel-cluster 27.06% <90.52%> (+3.34%) ⬆️
sentinel-core 59.20% <4.87%> (-0.43%) ⬇️
sentinel-extension 46.14% <ø> (-0.05%) ⬇️
sentinel-logging 54.54% <ø> (ø)

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

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.

Improve the performance and latency for the cluster limiter
2 participants