Useful command line tools while performance testing

11 August 2009

Finding the optimal performance for a BizTalk configuration can be hard and time consuming. There are a lot of possible configurations and adaptable settings. Performance testing is a matter of starting tests over and over again using different sets of parameters. Before a new test is started the servers should be reinitialized to make sure every test will have the same starting point. I found the below command line tools and commands very useful when doing this. I created a script to automate this initialization process so that boring manual work before each test is minimal.

First some obvious commands:

net stop “BizTalk Service BizTalk Group : BizTalkServerApplication”

net start “BizTalk Service BizTalk Group : BizTalkServerApplication”

iisreset /stop

iisreset /start

Use these commands to respectively:

  • stop host instance
  • start host instance
  • stop IIS
  • start IIS


PSService.exe makes it easy to start and stop services on remote systems. If you for example want to stop or start the SQL Server agent on a remote SQL server hosting the BizTalk databases you can use:

psservice.exe \\MySqlServer stop SQLServerAgent

psservice.exe \\MySqlServer start SQLServerAgent

PSService is part of the SysInternals toolkit and can be downloaded from here

Clear event logs

I also wanted to start my tests with clear and clean eventlogs. I found the WMI ‘Clear event log’ script by Mark Fairpo for this purpose. To clear event logs I used this command:

ClearEvt.wsf Application Security System

Performance monitoring

To be able to monitor and see test results after the has finished we need to define some counter logs in performance monitor. Those logs store performance counter information during the test. Examples are memory usage, network usage, BizTalk spool table, etc, etc. You can start and stop those logs from the command line using the logman.exe tool.

The commands are:

Logman.exe Stop “BizTalk Performance Counters”

Logman.exe Start “BizTalk Performance Counters”

This will stop and start the counter log named “BizTalk Performance Counters”

Clear Messagebox and Tracking databases

Finally it is very important to start each test with a clean messagebox and tracking database. You easily achieve this by executing the following query:

USE BizTalkMsgBoxDb

EXEC dbo.bts_CleanupMsgbox


exec dbo.dtasp_CleanHMData

Be aware that the first mentioned stored procedure doesn’t do anything by default (it is an empty stored procedure). You need to load it the first time from the file ‘msgbox_cleanup_logic.sql’ located in the ‘Schema’ sub folder of the BizTalk program folder. Also be careful with the parameters you provide to this stored procedure. If you use the wrong parameters all subscriptions will be wiped and you’ll have redeploy all BizTalk applications.

If you put the above SQL statements in a script you use it from the command line, like:

sqlcmd.exe -S MySqlServer -i d:\testscripts\init_bts_db.sql

I hope these commands are useful to other people too.

Random File Message Creator Component for LoadGen

18 June 2009

LoadGen is my favorite tool to perform automatic testing in BizTalk. It is easy to configure and extensible.

When I want to mimic the characteristics of the BizTalk production environment in a test lab as close as possible, LoadGen is the way to go. The load, in terms of number of messages per time unit, can be easily set and tuned by changing values in the LoadGen configuration file.

As said before I want to get as close as possible to the production environment. This also means that I want to use messages that are close to (or better equal to) the production environment.

LoadGen comes with template functionality that you can use to change the message content before passing the message on to BizTalk. This functionality is a bit limited to my opinion.

What I wanted to do is copy a batch of messages from production and use them in my test. To be able to do this I had to write a simple ‘MessageCreator’ component for LoadGen.

A ‘MessageCreator’ is a component that implements the ‘IMessageCreator’ interface found in LoadGen.dll. The ‘MessageCreator’ is called whenever the LoadGen run-time needs a new message. Its task is to create the message and pass it back to the run-time. After that the run-time passes the message to the configured transport components. (Actually the ‘MessageCreator’ fills an internal queue from which other threads dequeue messages).

The default ‘MessageCreator’ that comes with LoadGen is only capable of using a single file for input so I created a new one that:

  • - builds a list of files in a specific folder
  • - random picks a file from the list
  • - uses this file to create the new message

The code is straightforward. The ‘CreateNewMessage’ is the main method responsible for creating the message:


It calls two helper methods ‘CreateFileList’ and ‘GetFileFromList’:


I used the following LoadGen configuration file for my test:


The ‘MessageCreator’ is put in synchronous mode to make sure it create unique messages for all the client threads.

The ‘SrcFilePath’ path contains a pointer to a file where I actually only need the folder. Unfortunately LoadGen fails when there is no file at the end of the path. Internally I only use the path. The same applies to ‘TemplateFilePath’. I don’t need that here but the run-time for this setting.

In this sample I skipped the implementation of the ‘OptimizeFileSizeLimit’ property to keep things simple. I also did not need in in my test. The ‘OptimizeFileSizeLimit’ can be configured in the configuration file and basically tells the LoadGen run-time whether or not it is dealing with a large messages. If this is the case the creation of the message might be performed in another, more optimized way. The samples provided with LoadGen use this to skip file transport component and directly stream from the message component.



Get every new post delivered to your Inbox.