Sunday, August 19, 2007

Web Service Testing with LoadGen

Yes, you may have heard of this tool referred to as 'BizTalk LoadGen', but in reality, it works very well for generating load against most types of endpoints.  Don't let the BizTalk name fool you.

Maybe you have a web service that you want to drive some load against to verify performance or stability?  Borland Silk Performer, or Mercury LoadRunner, are excellent testing tools (I've used both), however, in many cases they can be a little heavy handed.  If your unfamiliar with those aforementioned toolsets, then trying to learn their in's and out's just to drive a little load against a singular web service is overkill. 

However, with a little patience, and the documentation, you can be up and running driving load against your web service in no time!  No more hand coding a test harness to drive the load, or monkeying with those pesky thread pools.  

Here is a sample web service implementation to illustrate the point:

namespace shobu.samples
/// <summary>
/// Summary description for MessageService
/// </summary>
[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class MessageService : System.Web.Services.WebService

public string Echo(string message)
Debug.WriteLine("Echo: " + message);

return message;


Now, a simple LoadGen configuration file and we can drive different workloads against the service.  Here is a sample LoadGen configuration file.  Refer to the LoadGen documentation for some of the details.


<StopMode Mode="Files">


<Transport Name="SOAP">

<Section Name="SoapSection">
<SOAPHeader>SOAPAction: ""</SOAPHeader>
<SOAPPrefixEnv>&lt;soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap=""&gt;&lt;soap:Body&gt;</SOAPPrefixEnv>
<!-- US-ASCII Or UTF-8 Or UTF-16BE Or UTF-16LE or UNICODE -->


Some of the things to note:

  • NumThreadsPerSection - number of threads handling each workload.  I believe this applies to all sections, so there is not way that if  I had two workloads in one configuration file, SOAP and File, that I could assign a different thread count to each section's thread pool.  Don't quote me on that, I've not tried it.
  • SOAPHeader - I don't believe you can apply multiple SOAP headers.  Here, we are really just applying the necessary SOAPAction.

Control the arrival rate by modifying the NumThreadsPerSection, SleepInterval and LotSizePerInterval elements.  Modify the workload by adding additional sections.  e.g. you have multiple services  you want to test on your server.

Change from a load test to more of a stability test by changing the StopMode to "Time" and allowing it to run overnight, or longer, while recording performance data of your service.

Here are the contents of the file (soap.txt) referenced by the SrcFilePath element:

<Echo xmlns="">
<message>hello, world</message>

LoadGen also has the ability to use MessageCreators to make your messages more dynamic.  For example, I could vary the string passed to the service on each call.  I'll look into that a little further soon.

Download LoadGen from Microsoft and give it a try. 

1 comment:

  1. Hi Zach,
    I am facing an issue while testing with LoadGen. Its is always generating 5 files always eventhough the StopMode NumFile =1Even if I change the Numfiles to 2 or more, it sends 5 files.
    Could you check what is going wrong