Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run my application in a simulated low memory, slow CPU environment

I want to stress-test my application this way, because it seems to be failing in some very old client machines.

At first I read a bit about QEmu and thought about hardware emulation, but it seems a long shot. I asked at superuser, but didn't get much feedback (yet).

So I'm turning to you guys... How do you this kind of testing?

like image 698
dario_ramos Avatar asked Jul 22 '11 12:07

dario_ramos


4 Answers

I'm not sure about slowing a CPU but if you use a virtual machine, like VMWare, you can control how much RAM is actually used. I run it on a MBP at home with 8GB and my WinXP VM is capped at 1.5 GB RAM.

EDIT: I just checked my version of VMWare and I can control the number of cores it can use. It's definitely not the same as a slower CPU but it might highlight some issues for you.

Since it's not entirely clear that your app is failing because of the old hardware or the old OS, a VM client should allow you to test various versions of OSes rather quickly. It came in handy for me a few years back when I was trying to get a .Net 2.0 app to run on Win98 (it can be done though I don't remember how I got it working...).

like image 154
Austin Salonen Avatar answered Nov 19 '22 10:11

Austin Salonen


Virtual Box is a free virtual machine similar to VMWare. It also has the capacity to reduce available memory. It can restrict how many CPUs are available, but not how fast those CPUs are.

like image 21
Aperium Avatar answered Nov 19 '22 10:11

Aperium


Try cpulimit, most distro includes it (Ubuntu does) http://www.digipedia.pl/man/doc/view/cpulimit.1

like image 3
ern0 Avatar answered Nov 19 '22 09:11

ern0


If you want to lower the speed of your cpu you can easily do this by modifying a fork bomb program

int main(){
     int x=0;
     int limit = 10

     while( x < limit ){

         int pid = fork();
         if( pid == 0 )
                 while( 1 ){}
         else
             x++;
    }

}

This will slow down your computer quite quickly, you may want to change the limit variable to a higher number. I must warn you though this can be dangerous, because if implemented wrong you could fork bomb your system leaving it useless unless you restart it. Read this first if you don't understand what this code will do.

like image 2
dbarnes Avatar answered Nov 19 '22 11:11

dbarnes