Configuring Thread Items

Thread Items offer a range of sophisticated options for configuration of how they start, stop and execute threads. This section explains these configuration options in detail.

For reference, a diagram below is shown of the Thread Item properties page:

Thread Item

Setting the Number of Threads

When you begin load testing a web site you need to determine how much load you wish to try and create. This in turn depends on many factors and constraints, and of course, on the requirements of your web site. The following are points to consider when setting the maximum number of Threads:

  • Actual Load Created per Thread - Many people begin by assuming that each thread corresponds to one real-world person browsing your web site. However this is false in many situations, because when Badboy browses your web site, it does so as fast as it possibly can. It does not wait between playing items in the script the way humans do - to read the page contents or to fill out forms, for example. Because of this, one Thread usually corresponds to more than one real world user. In fact, when using the Raw Browser Engine, a single thread can create a comparable load to that of dozens of real world users, depending on your web site. If you wish to make each Thread more closely match the behavior of a real-world user, add Timers to your script to add a realistic "think time" between each interaction in the script. In that case you can begin to consider a single Thread as approximating a single user.
  • How much Load can your Computer Produce? - each Thread you create doesn't just add load to your web server - it also uses resources on your own computer and your network. At some point you may find that the Threads you create slow down because the Threads have saturated the available resources on the client computer rather than those on the server. This is especially true for the "heavy weight" MSHTML Browser Engines that simulate a real browser as part of the load test. Once you have reached this point your load test will no longer produce realistic results because you are using one computer where in real life your web site will have to deal with many hundreds or thousands of client computers. For this reason you should watch the amount of CPU, RAM and network bandwidth used by your load test and ensure that they stay within the limits that your computer is capable of producing. If you need to produce more load than a single client computer can create then you may need to use multiple computers running Badboy simultaneously to create that load.

How long Threads Run

When you start Threads, they do not continue running forever. Rather, they run for a programmed amount of time that is controlled by settings in the Thread Item properties. The primary setting for this is the Duration. Badboy offers three options for how to control the duration of a Thread Item's threads:

  • Until Step Exits - If you choose "until step exits" they will loop over and over, executing until the parent Step finished executing. This makes it easy to coordinate a test by putting all the items you want to test inside a single parent step. As soon as the step exits your threads will automatically begin stopping.
  • Fixed Time - This option will cause your threads to run for a fixed amount of time, regardless of all other factors. This means that your threads will keep running even if the step exits, or even if the whole script is finished playing.
  • Fixed Iterations - This option will cause each Thread Item to run exactly the specified number of iterations of the children of the Thread.

If you find your threads don't seem to be running, check if you chose "Stop when step exits" for duration. If you choose this option and your Script finishes playing your threads may be aborting before they even started. Try setting a fixed interval to experiment with playing your threads.

Gradual Starting/Stopping

Often it is not desirable to have threads all start at once because all the steps are then "synchronized" which does not mirror normal user behavior. For example, while it might be common for your web site to have 100 users at any one time, it would be very unusual for all those users to decide to login at exactly the same instant. Another problem is that starting all the threads at the same time does not allow you to observe the effects of how the system behaves as load increases. Badboy allows you therefore to start and stop threads gradually by setting a number of threads to start and an interval in seconds to space each group of threads by.

Thread Limitations

In addition to the limitations mentioned for the different Browser Engines, there are some obvious limitations when you are running items in threads as opposed to executing them in a real browser, since many items in Badboy depend on the presence of a real browser interface in order to work. These include

  • Mouse Clicks - since there is no browser window, mouse clicks in the window will not work. However Mouse clicks on other windows than the browser window may still work.
  • Keys - You generally cannot send key strokes to items in background threads. Note that the keys items will still play but they will send key strokes to whichever window is active. Usually this would be undesirable and thus it is not recommended to use these at all inside Thread Items

To see if items are not playing correctly in background threads, enable the log file and set it to INFO level in the Preferences. Then after playing your Thread Item you can look for any warnings in the log file which will tell you any items that are unable to play properly because of being embedded in a Thread Item. Of course, you can also add Content Checks to validate the returned HTML as well.

Using Different Data Across Threads

You may encounter situations where your script needs to ensure different data is used by each thread. For example, each thread might need its own login account if your system only allows a user to login to a single session at a time.

To achieve this easily, Badboy provides a special "threadNum" variable that you can use to access different data in different threads. An example of how to do this is illustrated in the following steps:

  • Create a variable (for example, "foo") and add a list of values to it. In this example, one value will be used by each thread that you run.
  • When you reference your variable in your script, do so in the form:

This will cause your script to access the value of "foo" according to the index $threadNum, which is set by Badboy for each thread automatically for you.

HTTP Authentication and Proxy Authentication

Badboy has elementary support for Basic Authentication in threads. You can enable this by setting environment variables as described in the table below:

Environment VariableEffect
BADBOY_AUTH_USERUser name supplied for HTTP Basic Authentication
BADBOY_AUTH_PASSWORDPassword supplied for HTTP Basic Authentication
BADBOY_PROXY_AUTH_USERUser name supplied for Proxy Authentication
BADBOY_PROXY_AUTH_PASSWORDPassword supplied for Proxy Authentication

Other Topics Related to Thread Items

Badboy Documentation Generated on Mon Dec 29 22:28:41 EST 2008