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

New CPU and memory usage metrics #888

Open
na-- opened this issue Jan 3, 2019 · 12 comments
Open

New CPU and memory usage metrics #888

na-- opened this issue Jan 3, 2019 · 12 comments

Comments

@na--
Copy link
Member

na-- commented Jan 3, 2019

It would be useful (especially after #570 is implemented) for k6 to measure and emit the used CPU and memory resources. Some open questions

  • what period? once every second seems reasonable, but it may be a bit too noisy
  • are there libraries that would allow us to do it in a consistent and cross-platform way?
  • do we measure the used memory/CPU by k6 or the total system usage? or both?
  • do we measure the raw values or percentages of total system RAM? or both?
@luizdesign
Copy link

I'm interest in this metrics!

@na--
Copy link
Member Author

na-- commented Feb 26, 2019

Another metric that might also be useful is the number of network connections that are currently open. And here's a library that could be used for getting some of those metrics in a cross-platform way: https://github.com/shirou/gopsutil/

@mstoykov
Copy link
Contributor

mstoykov commented Aug 8, 2019

It will also be useful to print a warning at the end of the test if the CPU/Mem has gone above a certain threshold.

Possibly abort the test if we go above 99% memory used ? for example

@na--
Copy link
Member Author

na-- commented Aug 8, 2019

hmm yeah, having a default threshold (though probably not an aborting one) that checks we don't exceed some amount of RAM usage would be useful, so that users know the result of the test run would be skewed...

@na-- na-- modified the milestones: v1.0.0, v0.26.0 Aug 27, 2019
@mstoykov
Copy link
Contributor

If you are at 99% memory usage(probably at 95 as well) you are probably about to get the kernel to kill k6 at which point killing ourselves and reporting is probably MUCH better UX

@na-- na-- modified the milestones: v0.26.0, v0.27.0 Oct 10, 2019
@na--
Copy link
Member Author

na-- commented Nov 11, 2019

Digging for something unrelated, I stumbled upon https://golang.org/pkg/runtime/#ReadMemStats
It definitely needs investigation, but a cursory reading makes me think that using HeapSys.HeapSys + HeapSys.StackSys + maybe other *Sys metrics should give us a reasonably accurate estimation of the used memory by k6?

@yangyaochia
Copy link

I am interested in this metrics!

@na-- na-- modified the milestones: v0.28.0, v0.29.0 Sep 9, 2020
@na-- na-- modified the milestones: v0.29.0, v0.31.0 Nov 3, 2020
@na-- na-- removed this from the v0.31.0 milestone Feb 24, 2021
@poponuts
Copy link

any updates on this? :)

@mstoykov
Copy link
Contributor

No, @poponuts.

This has not been a priority. Additionally, I don't think we have agreed on any of the questions in the original comment, which likely isn't going to happen until this gets higher priority, sorry.

@ghost
Copy link

ghost commented Oct 8, 2021

Hi, FWIW this would be really useful for us at Alteryx. When running tests on Gitlab runners we have no other way of tracking the CPU and memory use of the tests, so we can't see if we need to increase the resources available to our runners or not.

@timterrill
Copy link

This seems like a good idea. if a load gen uses more than 80% cpu its going to start having issues. as stated, probably want to at least provide a warning, and offer an optional "abort if cpu>xx%" or something like that.

memory is harder to determine (as if the kernel has a ton of RAM marked to be reclaimed, but the system shows it as used, we aren't going to have a problem, but if we have literally 95% actively used RAM that's different. So if the solution for RAM monitoring/alerting takes that into account that would be great.

@olegbespalov
Copy link
Contributor

Maybe k6 could also measure the open file handlers (/proc/sys/fs/file-nr) ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants