An easy way of load testing a web service

Last week we had to test the load of a web service we were implementing that was quite demanding in terms of memory consumption. We found quite useful the Linux command called watch.

Basically watch repeats the passed command each n seconds, what makes it good enough to mimic the behavior of one client making a request every n seconds.

Of course you can run different instances o the command at the same time to increase the load average and to check how your service is behaving under concurrent conditions.

watch [options] command

-b, --beep beep if command has a non-zero exit
-c, --color interpret ANSI color and style sequences
-d, --differences[=]
highlight changes between updates
-e, --errexit exit if command has a non-zero exit
-g, --chgexit exit when output from command changes
-n, --interval seconds to wait between updates
-p, --precise attempt run command in precise intervals
-t, --no-title turn off header
-x, --exec pass command to exec instead of "sh -c"

-h, --help display this help and exit
-v, --version output version information and exit

Example (assuming you have a greeting service running on your local):

watch --interval 1 curl -XGET http://localhost:8080/greeting

Leave a reply:

Your email address will not be published.

Site Footer