Skip to content

pradykaushik/system-load-generator

Repository files navigation

System Load Generator

Generate different kinds of system load.

System Requirements

  1. Java version 1.8+.
  2. Gradle version 6.3.

Compile

Run gradle build to compile the source code.

Run

Run gradle run followed by command line arguments that you want to specify.
The following command line arguments are supported.

  1. --help - Display the help string.
  2. --load-type <type> - Specify the type of load that you want to generate. The following are the supported types.

Load Generators

CPU Load Generator

CPU Load generator that constantly increase the CPU utilization of a machine from 1% to 100%. Forked from SriramKeerthi-Gist and added functionality.

Configuration

The following are the configuration parameters that are provided in the YAML config file. The configuration file, named cpuload_config.yaml, is to be stored in configs directory.

  • stepSize - TYPE: decimal value in the range (0.0, 1.0). This specifies the increase in CPU load for every cycle.
  • duration - TYPE: number. This specifies the number of milliseconds for which the CPU load needs to be maintained for, before being increased again.
  • isAlt - TYPE: boolean. Consider a time slice to be 100ms. In the default state (when isAlt is false), CPU load is generated by making the current thread sleep for (1 - load) * 100ms. We could, however, generate the same CPU load with a different CPU usage pattern, such as an alternating one. When isAlt is true, CPU load is generated by making the current thread sleep multiple times, but for shorter durations, within the considered time slice (100ms). This leads to an alternating CPU usage pattern to create the same CPU load.
  • segments - TYPE: number. This specifies the number of times the CPU usage alternates, when isAlt is set to true. Suppose, the time slice is 100ms, and segments = 2, then to generate a CPU load of 50%, the thread would sleep twice for 25ms, once every 50ms.

Below is a sample configuration for cpu load generator.

stepSize: 0.2
duration: 3000
isAlt: false
segments: 2

Load Average Generator

A 1-minute load average generator that constantly increases the load average for the past minute.

Configuration

The following are the configuration parameters that are provided in the YAML config file. The configuration file, named loadaverage_config.yaml, is to be stored in configs directory.

  • startLoadAverageCore - TYPE: decimal (default = 1/numCores). This specifies the starting value of 1min load average for a given core. This value signifies the number of processes that would be executed in the first minute.
  • steSize - TYPE: decimal (default = 0.2). This specifies the increase in load average to be generated every minute.

Below is a sample configuration for load average generator.

startLoadAverage: 0.25 # assuming quad-core machine.
stepSize: 0.2

CPU Load Generator with Memory Pressure

Generate CPU load with Memory pressure.

Configuration

The following are the configuration parameters that are provided in the YAML config file. The configuration file, named cpuload_memorypressure_config.yaml, is to be stored in configs directory.

  • minCpuLoadPercentage - Minimum CPU usage pressure.
  • maxCpuLoadPercentage - Maximum CPU usage pressure.
  • ramUsageBytes - RAM usage bytes.

Below is a sample configuration for cpu load with memory pressure generator.

minCpuLoadPercentage: 0.2
maxCpuLoadPercentage: 0.6
ramUsageBytes: 2048

Constant CPU Load Generator

CPU Load generator that generates a constant cpu load for a set duration. Wraps around SriramKeerthi-Gist.

Configuration

The following are the configuration parameters that are provided in the YAML config file. The configuration file, named const_cpuload_config.yaml, is to be stored in configs directory.

  • cpuLoad - TYPE: decimal. This specifies the cpu load to generate. A cpuLoad of 1.0 indicates 100% cpu load.
  • duration - TYPE: number. This specifies the number of milliseconds for which the CPU load needs to be maintained.

Below is a sample configuration for cpu load generator.

cpuLoad: 0.6
duration: 70000

Docker

System Load Generator can be run in a docker container using the below command.

docker run -t pkaushi1/system-load-generator:v2 [-h | --load-type=LOAD_TYPE]

Note that this will use the default configuration (see configs) for each load generation strategy.

To use a different configuration, update the corresponding file in configs and then bindmount it to the configs/ directory within the container using the command given below.

docker run -v $PWD/configs:/configs -t pkaushi1/system-load-generator:v2 [-h | --load-type=LOAD_TYPE]