Start your 30 day free trial.
START FOR FREE

CPU Experiment

Supported platforms:

The CPU experiment generates high load on a CPU.

How it works

The CPU experiment generates high load on the CPU by running expensive arithmetic operations across multiple threads (one for each CPU core targeted). You can specify how many cores to generate load on, what percentage of each core to consume, and how long to run the experiment for.

When the CPU experiment runs, the operating system (OS) scheduler decides how to balance CPU time across Gremlin, your application, and all other processes. In most cases, this means the CPU experiment won’t block other processes from running.

How CPU utilization is calculated

CPU experiments are additive up to the available CPU on the host. For example, if your host is currently using 20% CPU and you run a CPU experiment with CPU Capacity set to 25%, the host’s total CPU usage will increase to approximately 55%.

Container CPU limits and allocation

When a container (e.g., Docker or Kubernetes) has a CPU limit applied to it, and you’ve configured the experiment to consume a percentage of CPU, Gremlin will calculate the percentage based on the limit, not the host’s total CPU capacity. Since CPU limits can be fractional, Gremlin will round up to the nearest whole CPU before calculating the percentage.

For example, consider a container with a CPU limit of 3500m running on an 8-node host. When running a CPU experiment of 50%, Gremlin detects the 3.5 CPU limit and rounds up to 4. Then, it calculates 50% of 4, which means the experiment will use two cores (4 * 0.5 = 2).

As of 2.58.0: When the CPU experiment is run against a container target (including Kubernetes), the target's available CPU cores reflects its cgroup limits. This value is currently rounded up to the nearest whole CPU value. For example, a CPU experiment run against a container with a CPU limit of 500m will compute a maximum of 1 cpu available. Support for fractional CPUs in these environments may come in a subsequent release.

Options

Parameter Flag Required Default Version Description
Cores -c int False 1 0.0.1 The number of cores to try to utilize. Capped to the number of available CPUs.
Percent -p <0-100> False 100 2.11.0 The percent of each CPU to utilize.
All Cores -a False False 2.11.0 If set, target all available CPUs (cannot be used with -c parameter).
Length -l int False 60 0.0.1 The length of the experiment (seconds).

Privileges Required

On this page
Back to top