Code Monkey home page Code Monkey logo

system-load-generator's Introduction

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]

system-load-generator's People

Contributors

menny avatar pradykaushik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

system-load-generator's Issues

change "CPU" to "System" in the readme.

This project no longer just contains cpu load generation code.
Therefore, renamed it to "system-load-generator". However, we should update the README to reflect this.

Simulate load on set of hosts.

Currently, if we want to simulate load on different hosts, then we need to manually run the program on different hosts or use a scheduler to launch an instance on each of the given hosts (which might require additional setup).

We should provision for generating specified load on a set of hosts.
We can accept a load specification for each host and then schedule them for a given amount of time.

gradle build issue

it required gradle version 4.4
but if gradle version is 7+ it will not work

this need to be update in readme.md

Simulate constant load for period of time

Currently, there is no support for simulating a constant CPU/Memory load for a set period of time.

It seems that step size can be set to 0 but this would result in an infinite loop.

We should support specifying that a constant load needs to be generated (--constant-load command line flag).

add makefile

It would be beneficial to include a makefile to ease the process of compilation and execution.

update readme and dockerfile for memory pressure module.

  1. Instead of accepting number of cores and number of threads per core, you can use ProcessorArch.getProcessorArchInformation(). Once this is done, then SystemLoad.java can accept only [min-cpu-usage-pressure], [max-cpu-usage-pressure] and [memory-bytes-pressure]
  2. Update the README to include instructions to run SystemLoad.java.
  3. Update the Dockerfile to include the line (commented) to RUN SystemLoad.java.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.