A Method for simulating Load from different Desktop Browser Types

The Method

The following article will show you how to simulate different browser types hitting a site. The basic method is simple – Pick a Random number, then according to a distribution change the User Agent header type of the request to correspond to different types of browsers.

Just Cut and paste the following in a JS script - insert at the beginning of your clip.

//Call a random dist for User Agent .. i.e. Browser types var ua = jbGenerateRandomUserAgent();  $context.result.postMessage($context.result.LEVEL_INFO, "Calls returns .... " + ua); $prop.set("MessageClip", "soastaUserAgent",  ua );  //Now make sure you have searched and replace the HTTP Request Header user agent field with {%% prop : clip : soastaUserAgent %%}      function jbGenerateRandomUserAgent() {          /*******************************************************************       * About: Jason Buksh Created on 14rd Mar 2012       * Objective: Generate Random User Agent String       * Example:        * Return:       ******************************************************************/          var prob =  Math.floor(Math.random() * (99 ) );     var rval;      Var LOGINFO = 1;       if (prob > 0  && prob < 50 )     {         //IE              rval = 'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))';              }     else if ( prob < 70)      {         //FireFox          rval = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko) Version/5.1.3';         }     else if ( prob < 95 )     {         //Chrome         rval = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 ';     }     else if ( prob < 100 )     {         //Safari         rval = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10';     }          if ( LOGINFO == 1 )      {         $context.result.postMessage($context.result.LEVEL_INFO, "jbGenerateRandomUserAgent:: Prob = " + prob + " User Agent =" + rval);     }          return rval;  }

Implementation Details

Search and replace the user agent field with a property value. Set this property value in the initial call to the clip with a user agent field determined by a probability distribution.


  • This is a scalable solution - Only one clip is required to support multiple types
  • You need to change the request type of the initial request to dynamic for this to be effective. This means the server will detect the types of browser performing the request and serve different types of content.
  • Now as most major browsers are starting to conform to consistent standards the retrieved data will not vary significantly.
  • If there is an issue with a particular performance issues with a browser type – it will be difficult to pinpoint the browser type causing the issue.

Method B

The alternative method is to duplicate all tracks – and then change the user agent field at a clip level. This quickly becomes impractical if you have complex compositions.

Other Considerations

  • Connections: Different browsers have a different number of open connections to fetch resources. The average is now 6. However Firefox can use 8 and go as high as 15. IE uses 4 to 6 depending on the version. A different number of open connections will put a different load profile on the target architecture. If you really want to achieve this then multiple targets have to be created and assigned. Or a little bit of JS can be inserted to modify the target prior to a request.
  • Mobile: This method will probably not work – check the server side parsing does not redirect to a different CNAME. If this is the case, you need to re-record with an actual device. Changing the user agent fields will not work.
  • Ask Yourself - What are you actually attempting to achieve? Are you attempting to simulate different browser behavior or load? Performance testing is about simulating load on the server. If the server architecture doesn’t act significantly differently for different browser types then question the benefits this approach will give.
  • Functional Behavior: If the goal is to measure browser behavior during load – then run functional tests while load is being generated.