Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put server on heavy load for testing

Tags:

linux

unix

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.

like image 492
unleashed Avatar asked May 19 '11 08:05

unleashed


People also ask

What is high load on a server?

A high load average means that a system or server is overloaded and many processes are waiting for CPU time. So there will be a number of processes waiting for completion and it will be in the queue leads to load on the server. Major Causes of High Load. Overloaded server. Spamming.

What is a good server load?

Between 0.00 and 1.0, there is no need to worry. Your servers are safe! 1.5 means the queue is filling up. If the average gets any higher, things are going to start slowing down.


2 Answers

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 ;)

like image 66
Cédric Julien Avatar answered Oct 04 '22 21:10

Cédric Julien


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)

like image 20
The Bndr Avatar answered Oct 04 '22 23:10

The Bndr