I'm implementing a feature in my dockerized server where it will ignore some of the requests when cpu and memory utilization is too high.
I already found out how to get memory and cpu time used by the process inside container here, but I also need a way to get cpu limit and memory limit (set by Runtime Options) to calculate the percentage.
Also, I can read the load for the host system from /proc/loadavg
, is there a "per-container load" somewhere I can read?
I'm using Java/Kotlin on openjdk 14.
Update: I found out I can get memory limit from /sys/fs/cgroup/memory/memory.limit_in_bytes