-
Notifications
You must be signed in to change notification settings - Fork 8.1k
SystemRule calculate process cpu usage to support application running in container #1204
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
SystemRule calculate process cpu usage to support application running in container #1204
Conversation
Hi, thanks for contributing. Could you please sign the CLA here? And please make sure the email of your commits match your GitHub email. You may refer to the instruction here, or rebase your commits with the correct email. 感谢贡献,请将 commit 对应的 email 调整成与 GitHub 的 email 相匹配并 确认一下 CLA。 |
And could you please illustrate your design (and how you did it) in the PR description? |
Codecov Report
@@ Coverage Diff @@
## master #1204 +/- ##
============================================
+ Coverage 43.03% 43.05% +0.01%
+ Complexity 1570 1568 -2
============================================
Files 337 337
Lines 9877 9890 +13
Branches 1332 1332
============================================
+ Hits 4251 4258 +7
- Misses 5099 5102 +3
- Partials 527 530 +3
Continue to review full report at Codecov.
|
sure |
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.
Oh this PR was submitted months ago. Is the submitter still here?
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/system/SystemStatusListener.java
Show resolved
Hide resolved
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/system/SystemStatusListener.java
Show resolved
Hide resolved
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.
LGTM
Thanks for contribution and look forward for more! |
为什么不直接用double processCpuLoad = osBean.getProcessCpuLoad();获取呢? |
Describe what this PR does / why we need it
SystemRule currently use the host's cpu usage, so it doesn't support the application running in the container such as docker, etc. This PR leverage both the process cpu usage and host's cpu usage to support application running in container.
Does this pull request fix one issue?
NONE
Describe how you did it
In the SystemStatusListener, I leverage JMX to get processCpuTime, processUpTime and cpuCores(the number of cpu cores, and it is the number of cpu cores which assigned to the container if application running in container).
Then the process cpu usage can be calculated as below:
processCpuUsage := delta(processCpuTime) / delta(processUpTime) / cpuCores
After that, we can use the max value between host's cpu usage and processCpuUsage to check the system status
Describe how to verify it
Special notes for reviews