-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Docker] psutil reports memory stats about host instead of container #2100
Comments
Similar question asked in #2076. From what I can tell, there is facility in psutil to use a custom |
This is still very much an issue. |
Process memory is retrieved from To my understanding from this ticket (#2100) and #2076, reading
Also, psutil should be smart enough to understand if it's running in a container, and automatically return the right info. But I have no idea how, and I suspect it's gonna be messy. E.g. there are different container technologies out there, and I imagine they do things differently and not in a standard fashion. [1] could somebody check what |
Similar discussion in my Java-based project: oshi/oshi#2632 (comment) The issue with the proposed cgroup paths is that they are docker-only and there are other containers. TLDR: an API conforming to this spec is probably the way to go: https://github.com/opencontainers/runtime-spec/blob/main/spec.md |
Hey Daniel! Hope you're good.
Yeah, that's what I thought. I bumped into this excellent article that you linked in one of those tickets: Virtual memory
Swap
Others
|
This seems doable to me. @dbwiddis out of curiosity, did you implement this in oshi? |
Also not standard and quite a mess: |
Nope. I have utility functions that are one-liners to fetch those values for those who know they're running in Docker. But as you say, we may not even know that at runtime.
How about:
Not actually suggesting this, but it would work... |
The serious approach:
|
Apparently figuring out what process 1 is seems to be a really good clue.
vs. bare metal
|
Not sure why, but this is how it looks to me when I'm "logged" into a docker container:
I do have this file though:
|
Another thing I don't understand is that
|
|
Summary
When running
psutil
on AWS Fargate, when requesting memory info, metrics are reported for the underlying host machine instead of the container.Description
I run a containerized web application that uses
psutil
to determine when a process has used too much memory and needs to be killed and restarted. This mechanism stopped working on AWS Fargate because theprocess.memory_percent
value reported is for the underlying Fargate host (I believe), not the container. I have no visibility into the host by definition and so am surprisedpsutil
would report the host memory values. I know it's reporting the host memory values because my tasks are configured to use a constant maximum amount of memory (8Gb) but my rss percentage indicatespsutil
thinks there is more (when there isn't), causing my tasks to trigger OOM errors.Relevant code: https://github.com/4dn-dcic/fourfront/blob/master/src/encoded/memlimit.py#L51-L62
Output from CloudWatch:
Perhaps I am missing something here, but based on the percentage we can work backwards to see it is treating 16Gb as the memory limit, which is not the right value. I'm not sure where else it could be from if not from the host machine. It might be this is expected behavior under AWS Fargate, but such a limitation should be documented if so.
The text was updated successfully, but these errors were encountered: