unleashed
unleashed

Reputation: 925

Put server on heavy load for testing

I'm doing some testing on a Linux server and I need the server to be on a heavy load. I was wondering how I would simulate this? Right now the server goes upto 20% CPU but I need to force it to around 80% and do some testing to see how it copes.

Upvotes: 7

Views: 5659

Answers (2)

The Bndr
The Bndr

Reputation: 13394

If you are looking for generating cpu usage, so you have to choose commands, which are CPU intensive. For example generation random-numbers.

Try this:

dd if=/dev/urandom of=/dev/null

Add on of those line for every CPU core. If you have an dual-core CPU use:

dd if=/dev/urandom of=/dev/null &
dd if=/dev/urandom of=/dev/null &

Check the jobs with

jobs

End the jobs with kill %1 (where %1 is the number of job 1)

Upvotes: 2

Cédric Julien
Cédric Julien

Reputation: 80761

If you want to force CPU's occupation, try this :

for cpu in 1 2 ; do
   ( while true; do true; done ) &
done

If you want to simualte IO charge too, try with this :

for cpu in 1 2 ; do
   ( while true; do find / -type f -exec cp {} /dev/null \; ; done ) &
done

with for cpu in 1 2 for 2 cores, for cpu in 1 2 3 4 for 4 cores ;)

Upvotes: 12

Related Questions