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: adaptive load balancer of adaptive service #2067
feat: adaptive load balancer of adaptive service #2067
Conversation
|
This load balancer takes into account the recent request success rate and request latency, the effect is as follows. Flexible services are turned on at the marked line position. After that the QPS of different configured services is no longer the same, and the CPU load and latency of lower configured services are significantly reduced. |
Codecov Report
@@ Coverage Diff @@
## 3.0 #2067 +/- ##
==========================================
+ Coverage 44.60% 44.66% +0.05%
==========================================
Files 283 281 -2
Lines 17105 16841 -264
==========================================
- Hits 7630 7522 -108
+ Misses 8669 8532 -137
+ Partials 806 787 -19
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
cluster/metrics/ema.go
Outdated
|
|
||
| // EMA is a struct implemented Exponential Moving Average. | ||
| // val = old * (1 - alpha) + new * alpha | ||
| type EMA struct { |
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.
"EMA" and "SlidingWindowCounter" as metrics name might make others confused. Please give your approach a name, such as "hill climbing" (just an example), and move all of them to <Name>Metrics. If it will be extended to more approaches in the future, then they will be named <Name1>Metrics, <Name2>Metrics, etc.
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.
To make it clearer, please keep EMA and SlidingWindowCounter in each file, create a new file, named <Name>_metrics.go, then merge EMAMetrics and SlidingWindowCounterMetrics into <Name>Metrics.
| return c.size | ||
| } | ||
|
|
||
| func (c *SlidingWindowCounter) Add(_ int64) { |
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.
Can this parameter be deleted?
| c.count++ | ||
| } | ||
|
|
||
| func (c *SlidingWindowCounter) Value() int64 { |
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.
Value is not a thread-safe method.
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.
Is this PR for client? Will traffic limitation on the server side be submitted in another PR?
| * limitations under the License. | ||
| */ | ||
|
|
||
| package rolling |
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.
Please rename this file to sliding_window_counter_metrics.go.
|
Lgtm, thanks. |
Yes. |
|
Kudos, SonarCloud Quality Gate passed! |











What this PR does:
Provides an adaptive load balancer in unstable environments.
This is a component of adaptive service at the consumer side.
Which issue(s) this PR fixes:
Fixes #1834
You should pay attention to items below to ensure your pr passes our ci test
We do not merge pr with ci tests failed