-
Notifications
You must be signed in to change notification settings - Fork 529
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
Ingester: Limit read path based on CPU/memory utilization #5012
Conversation
99eb5a7
to
a53bef7
Compare
pkg/ingester/limiting.go
Outdated
return | ||
} | ||
|
||
cpuUtil := (cpuTime - lastCPUTime) / now.Sub(lastUpdate).Seconds() |
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.
Could we just fetch current CPU usage via the library?
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.
Interesting, hadn't seen that. In any case, we likely won't be using gopsutil by the time the PR is finalized. I'll try to learn from the Percent
implementation.
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.
Also, the Percent function isn't suitable, since it calculates the system's CPU utilization and not that of a single process (we want to know how much CPU the ingester process is using).
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.
I see on the other hand that there's a Process.Percent method. I'll investigate its implementation.
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.
Having checked the Process.Percent
implementation, it's essentially the same as mine AFAICT. Though, I wonder why the cpu.Percent
function subtracts Guest and GuestNice from the total CPU time, while process.Process.Percent
does not?? Guess it warrants some research.
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.
Yea, cpu.Percent
might only be good to use if Mimir is the only container running in an ingester pod, which it seems to be, at least in the Helm chart.
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.
Yeah, it's generally alone in its pod. I've never experienced otherwise. Also, Mimir can run outside of Docker/k8s, so have to support that usage (as opposed to using some Docker/k8s method of finding CPU load).
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.
(Note that since the original comment was made, the PR has changed into measuring utilization via cgroup v2 and cgroup v1 before it measures via the process' resource utilization.)
b6a5f40
to
321314c
Compare
42f9678
to
8bee2cf
Compare
66106c8
to
fa42b92
Compare
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Marco Pracucci <marco@pracucci.com> Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
0be5820
to
21b157c
Compare
What this PR does
In the ingester, limit read path based on CPU/memory utilization. Read requests are rejected if the configured CPU/memory utilization threshold is exceeded, with HTTP code 503 (service unavailable).
CPU and memory utilization are obtained from one of the following, in order:
The implementation is Linux only, for simplicity. The feature is marked as experimental though, so it should be OK to not have a cross-platform solution (yet?).
CPU utilization is calculated as an exponential weighted moving average over the last minute.
TODO
Which issue(s) this PR fixes or relates to
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]