Open rociomroman opened 11 months ago
can you PTAL: @uditgaurav
We may need enhance the logic for this here but it won't be straight forward.
CPUs are designed to be either fully utilised or idle, so trying to precisely control them to be used at a certain intermediate level (like 50% or 75%) is complex. The OS scheduler is designed to allocate CPU time to processes based on need and priority, not to artificially limit a process to a certain percentage of CPU time.
The 'cpu-hog' method, starting from Litmus version 1.13.8, eliminates the dependency on the target container's base image and resolves compatibility issues with scratch images, which were present in the exec approach.
It leverages the container's cgroup and pid namespace to run the stress-ng process, allowing for resource consumption without the need for container exec-ing, thereby addressing the shortcomings of previous methods.
Additionally, this method offers improved recovery mechanisms in the event of an abrupt termination, ensuring a more resilient and stable chaos testing process.
You will able to provide the the percentage of cpu using the --cpu-load
as you explained.
Details:
stress
package to support cpu load and cpu cores envs). I understand that Litmus uses md5sum to induce the consumption of the cpu resources. However we're only able to specify entire cpu core here using the cpu core tunable. We want to target half a core for a special use case.I've read the stress package makes this easy with the following command:
stress --cpu 1 --cpu-load 0.5 --timeout 60s
Unfortunately, we're unable to use thestress
linux packages at the moment. Looking to leverage a basic cpu utility available in the linux distros by default. From my research,taskset
could be useful but it only allows for whole core, not fractions of a core. Any insights are highly appreciated. Thank you