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: auto concurrency limiter of adaptive service #2114

Merged
merged 8 commits into from Dec 19, 2022

Conversation

CoolIceV
Copy link
Contributor

@CoolIceV CoolIceV commented Nov 9, 2022

What this PR does:
Provides an auto concurrency limiter in unstable environments.
This is a component of adaptive service at the provider side.
The component at the consumer side is in #2067.

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

  • All ut passed (run 'go test ./...' in project root)
  • After go-fmt ed , run 'go fmt project' using goland.
  • Golangci-lint passed, run 'sudo golangci-lint run' in project root.
  • Your new-created file needs to have apache license at the top, like other existed file does.
  • All integration test passed. You can run integration test locally (with docker env). Clone our dubbo-go-samples project and replace the go.mod to your dubbo-go, and run 'sudo sh start_integration_test.sh' at root of samples project root. (M1 Slice is not Support)

@CoolIceV
Copy link
Contributor Author

CoolIceV commented Nov 9, 2022

This concurrency limiter uses CPU load as a limit switch to automatically calculate the capacity of the service when the load is too high, the effect is as follows.

image

QPS increases gradually over time. When the CPU load is high, flow limiting is automatically turned on. Then successful requests and CPU load are maintained at a relatively stable level.


exploreRatio float64
emaFactor float64
noLoadLatency float64 //duration
Copy link
Member

Choose a reason for hiding this comment

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

nit: //duration -> // duration

startSampleTimeUs int64
lastSamplingTimeUs *atomic.Int64
resetLatencyUs int64 // time to reset noLoadLatency
remeasureStartUs int64 //time to reset req data (sampleCount, totalSampleUs, totalReqCount)
Copy link
Member

Choose a reason for hiding this comment

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

nit: //time -> // time

defer func() {
ticker.Stop()
if err := recover(); err != nil {
go cpuproc()
Copy link
Member

Choose a reason for hiding this comment

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

Add a warning log to let users know what is happening here.

SampleWindowSizeMs = 1000
MinSampleCount = 40
MaxSampleCount = 500
CpuDecay = 0.95
Copy link
Member

Choose a reason for hiding this comment

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

nit: CpuDecay -> CPUDecay

}
}

func CpuUsage() uint64 {
Copy link
Member

Choose a reason for hiding this comment

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

CpuUsage -> CPUUsage

@CoolIceV CoolIceV changed the base branch from 3.0 to 3.0-adaptive-stream November 24, 2022 11:54
@sonarcloud
Copy link

sonarcloud bot commented Nov 24, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@AlexStocks
Copy link
Contributor

@nanfeng1999 lizhenyuan

@justxuewei justxuewei merged commit d41d88e into apache:3.0-adaptive-stream Dec 19, 2022
@justxuewei
Copy link
Member

Merged into 3.0-adaptive-stream branch to make the running benchmark more convenient. Once the current version is in line with expectations, it will be merged into 3.0 branch.

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.

None yet

3 participants