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.
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.
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.
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 ;)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With