merlimat opened a new pull request #7475:
URL: https://github.com/apache/pulsar/pull/7475
### Motivation
When using CPU limits on a docker container, the CPU usage on the broker
load report will result incorrect.
We're reporting the CPU usage such as:
```json
"cpu" : {
"usage" : 8.130785075483013,
"limit" : 200.0
},
```
While the limit is correctly reflecting the 2 CPU limitation on the
container, the usage is read from `/proc/stat` is referring to the all the CPUs
in the host machine.
The effect of this is that the broker will appear with a lower CPU % usage
and the load shedding will not be automatically triggered, even though the
broker might be using the entire CPU quota allocated.
Instead, we need to read the usage from `/sys/fs/cgroup/cpu/cpuacct.usage`.
This will work both inside and outside of a container.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]