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 = "http://shobu.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class MessageService : System.Web.Services.WebService
{

[WebMethod]
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.

<LoadGenFramework>
<CommonSection>
<LoadGenVersion>2</LoadGenVersion>
<OptimizeLimitFileSize>204800</OptimizeLimitFileSize>
<NumThreadsPerSection>12</NumThreadsPerSection>
<SleepInterval>2000</SleepInterval>
<LotSizePerInterval>1</LotSizePerInterval>
<RetryInterval>10000</RetryInterval>

<StopMode Mode="Files">

<NumFiles>3600</NumFiles>
<TotalTime>3600</TotalTime>
</StopMode>

<Transport Name="SOAP">
<Assembly>SOAPTransport.dll/SOAPTransport.SOAPTransport</Assembly>
</Transport>
</CommonSection>

<Section Name="SoapSection">
<SrcFilePath>c:\temp\loadgen\soap\soap.txt</SrcFilePath>
<DstLocation>
<Parameters>
<URL>http://localhost/Samples/MessageService.asmx</URL>
<SOAPHeader>SOAPAction: "http://shobu.com/Echo"</SOAPHeader>
<SOAPPrefixEnv>&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soap:Body&gt;</SOAPPrefixEnv>
<SOAPPostfixEnv>&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;</SOAPPostfixEnv>
<IsUseIntegratedAuth>False</IsUseIntegratedAuth>
<ResponseMsgPath>c:\temp\loadgen\soap\responses</ResponseMsgPath>
<DstEncoding>UTF-8</DstEncoding>
</Parameters>
</DstLocation>
</Section>
<!-- US-ASCII Or UTF-8 Or UTF-16BE Or UTF-16LE or UNICODE -->

</LoadGenFramework>

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="http://shobu.com/">
<message>hello, world</message>
</Echo>

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
    Regards
    Sith

    ReplyDelete