I would like to take a moment to write about the benefit of Load Testing your BizTalk solutions before they go live and provide a very simple walkthrough of a Load Test. Often the true performance characteristics of your BizTalk environment will not be revealed until the moment that it has been set under real-world workload. It can be a traumatic experience for your team to discover once you have gone live that you have a serious bottleneck problem. Wouldn't it be nice to have a tool that would allow you to easily place some serious load on your solution before you go live?
Luckily the Microsoft BizTalk Product Group has already built a solution to help us out. They have created a much underappreciated tool called innocuously enough LoadGen 2007. This can be downloaded for free here.
Let's run through installing and setting up a very simple Load Test, shall we? Bear in mind for this example we are just trying to set up an environment where we can create some serious load, it doesn't have to be fancy just as long as it works. This test was done using Microsoft BizTalk 2006 R2 and LoadGen 2007.
Part 1, Install LoadGen: Once installed you should have folder structure as follows,
- Under the LoadGen 2007 install directory you should find a Bins, ConfigFiles and Docs folder.
- Bins folder contains the DLL's that you will use for your tests (depending upon which adapters you are using in your BizTalk solution)
- ConfigFiles contains XML templates to help you set up some tests
- Docs contains a number of samples/examples
- The Bins folder contains a number of DLL's and (very) important the LoadGenConsole.exe (this is where we start up our tests)
- For this short demo I am going to be using the FileTransport.dll
Part 2, Search for file "FileToFileLG.xml" , found within folder %ProgramFiles%\LoadGen2007\ConfigFiles\ConsoleConfigFiles. This is the file that we will use to drive out tests for this example. From a command prompt we call the LoadGenConsole.exe and feed it an XML file containing our test configuration. I have edited this file (shown below) to run my test using the FileDrop locations configured for my test BizTalk application. I have used the EAI tutorial found on MSDN to test with (see part 3 hereunder). Don't panic over the number of configurable items in your initial test, remember we just want to set up a simple Load Test.
<LoadGenFramework> <CommonSection> <LoadGenVersion>2</LoadGenVersion> <OptimizeLimitFileSize>204800</OptimizeLimitFileSize> <NumThreadsPerSection>5</NumThreadsPerSection> how many threads will be used to do work <SleepInterval>200</SleepInterval> <LotSizePerInterval>25</LotSizePerInterval> <RetryInterval>10000</RetryInterval> <StopMode Mode="Files"> <NumFiles>5000</NumFiles> how many messages to be sent <TotalTime>3600</TotalTime> time span over where the work is done </StopMode> <Transport Name="FILE"> <Assembly>FileTransport.dll/FileTransport.FileTransport</Assembly> </Transport> <ThrottleController Mode="Custom"> <Monitor Name="File"> <Assembly>FileMonitor.dll/DropLocationFileMonitor.DropLocationFileMonitor</Assembly> <ThresholdRange>1000-2000</ThresholdRange> <SleepInterval>1000</SleepInterval> <Parameters>C:\Temp\IN</Parameters> </Monitor> <ThrottleCondition>File</ThrottleCondition> </ThrottleController> </CommonSection> <Section Name="FileSection"> Each <Section> is a test <SrcFilePath>C:\TEMP\EAIRequest001.xml</SrcFilePath> Static test files location <DstLocation> <Parameters> <DstFilePath>C:\Temp\IN</DstFilePath> Where the files will be dumped </Parameters> </DstLocation> </Section>
<Section Name="FileSection"> <SrcFilePath>C:\TEMP\EAIRequest501.xml</SrcFilePath> Static test files location <DstLocation> <Parameters> <DstFilePath>C:\Temp\IN</DstFilePath> </Parameters> </DstLocation> </Section> </LoadGenFramework>
Part 3, We need a BizTalk Solution: (actually you could set up the load test without even having a BizTalk solution running. The point of this exercise is to pump a bunch of files into a folder to simulate a 'load') . A running BizTalk solution is nice to have though because you can see the files being picked up and delivered to their destinations. In order to keep things simple I used an AEI BizTalk tutorial found on MSDN, The EAI tutorial can be found here. This tutorial is nice for our purposes as it uses only the File Adapter (more info on adapters found here). The solution has 1 receive endpoint and 2 send endpoints as well as an very simple orchestration. The configuration is as follows:
In my test case:
- Receive port is configured to pick up on: C:\FileDrop\IN
- Send port #1 is configured to drop into: C:\FileDrop\ERPOut
- Send port #2 is configured to drop into: C:\FileDrop\Declined
Notice how these file paths can be found in FileToFileLG.xml as described in Part 2 above.
Also important is the Orchestration that we will be testing with our load generator: This Orchestration has a single Distinguished field (Quantity) that will be used to in a Decide Shape to determine whether a request message will be send to the 'ERP' or moved to a Decline folder. This is just basically an IF/Else statement (IF Quantity <= 500 send message to 'ERP' ELSE transform a decline message and send to Decline).
Part 4, Create XML Request files. In order to test you will need to create some XML files. The name must be the same used in the SrcFilePath element within the LoadGen configuration file.
Request Message: expected accepted request due to Quantity <= 500
This message is called: EAIRequest001.xmlNotice where its' place is in the SrcFilePath section of the LoadGen configure file above.
Request Message: expected decline request due to Quantity > 500
This message is called: EAIRequest501.xmlNotice where its' place is in the SrcFilePath section of the LoadGen configure file above.
|<ns0:Request xmlns:ns0="http://EAISchemas.Request"> <Header> <ReqId>1234567</ReqId> <Date>Date_0</Date> </Header> <Item> <Description>Description_0</Description> <Quantity>1</Quantity> <UnitPrice>UnitPrice_0</UnitPrice> <TotalPrice>TotalPrice_0</TotalPrice> </Item> </ns0:Request>||<ns0:Request xmlns:ns0="http://EAISchemas.Request"> <Header> <ReqId>9876</ReqId> <Date>Date_0</Date> </Header> <Item> <Description>Description_0</Description> <Quantity>501</Quantity> <UnitPrice>UnitPrice_0</UnitPrice> <TotalPrice>TotalPrice_0</TotalPrice> </Item> </ns0:Request>|
Part 5, running the command prompt: fire up a command prompt! I chose to move my context to the Bin folder where my LoadGenConsole.exe was located and copied my FileToFileLG.xml file there as well. The syntax is simple [LoadGenConsole.exe <xml file to load>]. That's all there is to it.
Part 6, View the results. If everything went well you have just set X number (dependant upon NumFiles element) of files (EAIRequest001.xml & EAIRequest501.xnl) to the folder c:\Temp\IN. You should find X number of EAIRequest001 files in C:\FileDrop\ERPOut & X number of EAIRequest501 files C:\FileDrop\Declined (of course the names have most likely been changed possibly with a GUID depending upon how you have configured your endpoints in BizTalk)
Part 7, Identify and fix your bottlenecks. Once you have found your Maximum Sustainable Throughput (basically how many messages you can pump through the system in an hour) you can start to tweak your system to improve performance. You need to ensure that you are monitoring the correct Performance Counters and it is essential that your system is cleaned up before every run of the test.
Please notice in the LoadGen Bin folder that there are a number of DLL's there including those for SQL, MSMQ and SOAP. You can load test virtually any solution with these tools. If you were to use BizUnit then you could build a library of iterative business cases that would drive your load generation. (www.codeplex.com/bizunit).
I hope that this was informative.