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

Memory usage is wrong (usage vs cache)? #42

Closed
tatref opened this issue May 30, 2018 · 4 comments
Closed

Memory usage is wrong (usage vs cache)? #42

tatref opened this issue May 30, 2018 · 4 comments

Comments

@tatref
Copy link
Contributor

tatref commented May 30, 2018

Hi,

It seems that the memory usage reported by the API memory_stats/usage is not correct if the container is doing a lot of IO and thus has lots of disk cache.

Example of a mysql database:

# docker stats
MEM USAGE / LIMIT     MEM %
329.6MiB / 2.868GiB   11.22%

The API shows:

check_docker.sh --containers prd-piwik-mysql --memory 500:1000:m
WARNING: prd-piwik-mysql memory is 784.765625m|prd-piwik-mysql_mem=784.765625m;500;1000;0;2936.6015625

This seems related to the issue moby/moby#10824

@tatref
Copy link
Contributor Author

tatref commented May 30, 2018

Further digging into the API, I found the following:

    "memory_stats": {
        "stats": {
            "cache": 477356032,
            "rss": 345579520,
        },
        "usage": 822935552
    },

I'm not sure how to fix this properly though.

What do you thing about taking just rss? or usage - cache?

@tatref
Copy link
Contributor Author

tatref commented Jul 4, 2018

I did the following change under check_memory:

    usage = inspection['memory_stats']['usage'] / UNIT_ADJUSTMENTS[units]
    cache = inspection['memory_stats']['stats']['cache'] / UNIT_ADJUSTMENTS[units]
    real_usage = usage - cache

Here is the check output:

OK: prd-piwik-mysql memory is 353.640625m|prd-piwik-mysql_mem=353.640625m;500;1000;0;2935.87890625

Compared with docker stats:

MEM USAGE / LIMIT     MEM %
353.6MiB / 2.867GiB   12.05%

@tatref
Copy link
Contributor Author

tatref commented Jul 11, 2018

Oups, I just realized you fixed this a while ago!

@tatref tatref closed this as completed Jul 11, 2018
@timdaman
Copy link
Owner

Oh, sorry. I didn't realize that you were reporting the same issue. Glad it is working for you now.

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

No branches or pull requests

2 participants