views:

71

answers:

2

Can someone recommend a utility to simulate a resource constraint on a Linux system. I need to test performance of the system under stress - both memory and CPU.

I would need something that would allocate an amount of memory, therefore leaving less for the program I am testing.

And also would use up all available CPU.

I am preferring an out of the box utility, instead of writing one myself.

+2  A: 

man ulimit

You can use it to limit how much memory and CPU time a process can use.

John Millikin
This will not do what the OP wants. Hitting the memory limit will result in `malloc` returning `NULL`, and hitting the soft and hard CPU time limits will result in the process recieving `SIGXCPU` and `SIGKILL` respectively. Neither of these is what will happen if memory and CPU time are being consumed by other processes on the machine, which is what the OP is trying to simulate.
caf
+2  A: 

The stress program sounds like what you want - it is described thus:

stress is a simple workload generator for POSIX systems. It imposes a configurable amount of CPU, memory, I/O, and disk stress on the system.

caf
This is perfect
Timur Fanshteyn