When tuning messaging engine threads per cpu lower from defaults can help performance

Say you have a large flatfile in an application that does messaging only.   You drop a single file and you notice elevated cpu for the receive host for several minutes.    What’s happening in the host is that a single messaging thread is using the ffdasm to disassemble the flat file.   This is a very cpu intensive activity

Now you drop 100 large flatfiles.  Since messaging engine threads per cpu is set to 20, if you have a two processors, then there will be 40 messaging engine threads created and operating on 40 inbound flatfiles.    cpu still goes to 100%, but it takes longer for the first flatfile to be processed because other threads are taking valuable cpu resources.  

In testing on a two processor system I was able to get the best end to end performance by specifying that only one messaging engine thread per cpu be used on the receive host when performance testing with 100 files.  Tuning messaging engine threads per cpu to a lower value results in faster processing of the first file through the system and additionally faster overall processing.

1 messaging engine thread per cpu on the receive host about 4 minutes to process the first file.  1 hour and 30 minutes for all files

10/21/2011  02:46 PM                 set messaging engine threads to 1 for full test.txt

10/21/2011  02:50 PM         2,752,368 {FC0AD608-1F76-43A2-B7D5-44DDB66E66DF}.xml

10/21/2011  04:16 PM         2,752,368 {F7241E83-C7F1-428D-A5DD-2582CF8ABE20}.xml

2 messaging engine threads per cpu on the receive host about 4 minutes to process the first file.  1 hour 42 minutes to finish all approx..

10/19/2011  04:29 PM               set messaging engine threads to 2 for full test.txt

10/19/2011  04:33 PM         2,752,368 {C29DB82A-98E8-4B41-B917-093DDC708D21}.xml

10/19/2011  05:02 PM         2,752,368 {E9AFFEC2-B60B-446C-9D63-1BBBB2B2FD12}.xml  33rd file in 34 minutes.  Had to stop test early summary

extrapolated.

4 messaging engine threads per cpu on the receive host  10 minutes time to first message and 1 hour and 39 minutes total processing time.

10/19/2011  06:06 PM                 set messaging engine threads to 4 for full test.txt

10/19/2011  06:16 PM         2,752,368 {E96CD77C-8D24-4BB9-A111-871594B06F3F}.xml

10/19/2011  07:45 PM         2,752,368 {2F2EE1F9-C9F0-44A9-B2D1-1A02BC9F7EAD}.xml

20 messaging engine threads per cpu on the receive host (the default setting) 18 minutes.  1 hour and 42 minutes for all files to be processed.

10/20/2011  09:35 AM                 set messaging engine threads to 20 for full test.txt

10/20/2011  09:53 AM         2,752,368 {9BA6A42F-A634-4FEF-A29E-F16A774D823F}.xml

10/20/2011  11:17 AM         2,752,368 {262F3035-CACF-423A-BDFA-5EA817D2639B}.xml

50 messaging engine threads per cpu on the receive host  23 minutes before first file is processed.  1 hour 54 minutes for all files to be processed.

10/20/2011  02:56 PM                 set messaging engine threads to 50 for full test.txt

10/20/2011  03:19 PM         2,752,368 {40BF75AF-3935-4DC1-99C4-048CD61421D1}.xml

10/20/2011  04:50 PM         2,752,368 {5B72CC56-FB61-4A33-9186-3A3F954AC38A}.xml

BizTalk Orchestration Profiler 2010

BizTalk Orchestration Profiler 2010

BizTalk Orchestration Profiler is a really useful tool and one I would recommend to BizTalk developers building orchestration based solutions. It illustrates the degree of shape coverage for a given orchestration. It also facilitates the identification of latency issues and error prone shapes. The current release of the BizTalk Orchestration Profiler on CodePlex will not […]
Blog Post by: Colin Meade

Integration in the Cloud: Part 2 – Shared Database Pattern

Integration in the Cloud: Part 2 – Shared Database Pattern

In the last post, I kicked off this series of blogs addressing how we can apply classic enterprise integration patterns to cloud scenarios. Let’s look at the first pattern: shared database. What Is It? Sharing data via extract-transform-load (ETL) obviously isn’t timely. So what if system need the absolute latest data available? I might need […]
Blog Post by: Richard Seroter

Integration in the Cloud: Part 1 – Introduction

Integration in the Cloud: Part 1 – Introduction

I recently delivered a session at QCon Hangzhou (China) on the topic of “integration in the cloud.” In this series of blog posts, I will walk through a number of demos I built that integrate a variety of technologies like Amazon Web Services (AWS) SimpleDB, Windows Azure AppFabric, Salesforce.com, and a custom Ruby (Sinatra) app […]
Blog Post by: Richard Seroter

BizTalk Environment Maintenance from a DBA perspective

BizTalk Environment Maintenance from a DBA perspective

This is one of the common challenges we see in many enterprises. SQL servers will always be owned by a dedicated database team. The bigger the organisation, the partition between the BizTalk support team and database team will increase. One of the biggest challenges with this setup is, from DBA’s perspective they wanted to follow all the best practices, they normally follow as a standard for all the SQL Servers/Databases in the organisation. These may include things like standard backup procedures, indexing procedures, standard recovery model, their own SQL bookkeeping jobs etc.

This situation is a real red alert, BizTalk databases are special databases. A typical BizTalk installation at the minimum will have 4 databases BizTalkMsgBoxDb, BizTalkMgmtDb, BizTalkTrackingDb, SSODB. They are designed to work as a single group. There are certain dependencies between them. Example: Some of the SQL jobs are designed to move data from BizTalk message box to tracking DB, the Tracking subservice will also do similar thing to move data from message box. There are lot of chances for distributed transactions spanning across these databases.  So, the general rule of thumb is

"Do not treat your BizTalk databases as your standard database. It’s just a black box and you are not allowed to make any changes (there are few exceptions)"

BizTalk server by default comes with all the weapons required to maintain/protect its databases. The product is designed in a way to self maintain. The main challenge here is SQL DBAs are not fully aware of the BizTalk capabilities.  In this article we will see some of the routine jobs SQL DBA’s must be aware of when maintaining a BizTalk environment related databases.

1.    Know how to use Message Box Viewer/Terminator
2.    One time settings
3.    Make sure SQL Agent is running
4.    Procedures to rebuild indexes for BizTalk databases
5.    Monitor the growth of certain tables
6.    Monitor the size of databases
7.    Monitor transaction log sizes
8.    BizTalk 2010 Monitor BizTalk Server Job

Know how to use Message Box Viewer/Terminator
Message box viewer and Terminator tool are the two tools the DBA’s maintaining the BizTalk environment should be completely aware of. MBV is designed to identify all potential problems in the BizTalk environment that could be critical or need attention and present them in a nice report. Most of the BizTalk environment issues will come down to poorly maintained database(s); MBV is extremely good at picking them up. Full Q&A can be found here
http://blogs.technet.com/b/jpierauc/archive/2008/07/22/msgboxviewer-mbv-q-a.aspx

In earlier days people executed MBV, identified the issues and manually corrected the problems. But with latest version of MBV (10.3 and above), MBV produce a cleanup script, which can then be used with another tool called Terminator to fix the database issues either automatically or manually.

http://blogs.msdn.com/b/biztalkcpr/archive/2011/02/10/using-biztalk-terminator-to-resolve-issues-identified-by-biztalk-msgboxviewer.aspx

One time settings
Here are some of the steps you need to perform once the environment is setup.

1. Install the Latest BizTalk Server Service Pack and Cumulative Update

2. Disable the Auto Update Statistics and Auto Create Statistics options

You must disable the Auto Create Statistics and Auto Update Statistics options on the BizTalkMsgBoxDb database. To determine whether these settings are disabled, execute the following stored procedures in SQL Server:
exec sp_dboption ‘BizTalkMsgBoxDB’, ‘auto create statistics’
exec sp_dboption ‘BizTalkMsgBoxDB’, ‘auto update statistics’

You should set the CurrentSetting setting to off. If this setting is set to on, turn it off by executing the following stored procedures in SQL Server:

exec sp_dboption ‘BizTalkMsgBoxDB’, ‘auto create statistics’, ‘off’
exec sp_dboption ‘BizTalkMsgBoxDB’, ‘auto update statistics’, ‘off’

3. Set the Max Degree of Parallelism property correctly

On the computer that is running SQL Server and hosting the BizTalkMsgBoxDb database, set the Max Degree of Parallelism run_value and config_value properties to a value of 1. To determine the Max Degree of Parallelism setting, execute the following stored procedure against the Master database in SQL Server:

exec sp_configure ‘max degree of parallelism’

If the run_value and config_value properties are not set to a value of 1, execute the following stored procedure in SQL Server to set them to 1:

exec sp_configure ‘max degree of parallelism’, ‘1’
reconfigure with override

4. Make sure BizTalkMsgBoxDb and BizTalkTrackingDb data and log files are in separate drives, also if possible make sure you don’t put BizTalkMsgBox and BizTalkTrackingDb data files or log files in the same drive.

Rebuilding indexes
The only supported method to rebuild an index in the BizTalkMsgBoxDb database is to run the bts_RebuildIndexes stored procedure. On BizTalk Server 2006 and later versions, you can run the dtasp_RebuildIndexes stored procedure to rebuild indexes in the BizTalkDTADb database.

If lots of data is expected to build up in the BizTalkMsgBox database, you can periodically rebuild indexes during scheduled downtime. The same guidelines apply to the tracking database.

You can use the DBCC DBREINDEX SQL command to rebuild an index in the other BizTalk Server databases. For an example of how to use the DBCC DBREINDEX SQL command, right-click the bts_RebuildIndexes stored procedure, and then click Properties.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;917845

Monitor the growth of certain tables
Message Box Database (BizTalkMsgBoxDb)

Spool:
If the Spool tables have many records, many messages are currently active, dehydrated, or suspended. Depending on the size, the number of parts, and the fragmentation settings in these tables, a single message may spawn all these tables. Each message has exactly one row in the Spool table and at least one row in the Parts table. Create a benchmark for your BAU activities and make sure the spool table is not growing indefinitely. During you quite period when there are no BAU activities if you notice a large number of rows in this table, make sure unwanted suspended instance are cleared periodically. You can also use Message Box Viewer regularly to check if there are any unusual numbers of rows in the table and can use Terminator tool to safely remove them.

TrackingData_0_x and TrackingData_1_x
TrackingData_0_x: These four tables store the Business Activity Monitoring (BAM) tracked events in the BizTalkMsgBoxDb database for TDDS to move the events to the BAMPrimaryImport database.
TrackingData_1_x: These four tables store the tracked events in the BizTalkMsgBoxDb database for TDDS to move the events to the BizTalkDTADb database.

You make sure there is at least one host configured with tracking enabled. This will run TDDS subservice responsible for moving the data from message box db to BizTalkDTADb and BAMPrimaryImport

BizTalk Tracking Database (BizTalkDTADb)
dta_DebugTrace table typically becomes large in environments where orchestration shapes start/end is enabled. If there is no business value and if you got lots of orchestration in your solution, it’s better to clear the check box for ?Shape start and end? option in the orchestration(s) properties.

dta_MessageInOutEvents table typically becomes large in environments where ?Message send and receive? is enabled for orchestrations and/or pipelines. If these tracking events are not required, clear the check box for this option in the orchestration and/or pipeline properties.

If the dta_DebugTrace table and/or the dta_messageInOutEvents table in the BizTalkDTADb database are too large, you can truncate the tables manually after you stop the tracking host. The BizTalk Terminator tool also provides this functionality.

dta_ServiceInstanceExceptions table typically becomes large in an environment that regularly has suspended instances. dta_serviceinstances table grows every time the user terminates an instance. DTA Purge and Archive SQL Server jobs should take care of clearing this table, so make sure the jobs are running correctly.

BAMPrimaryImport
TDDS_FailedTrackingData
The TDDS_FailedTrackingData table gets populated whenever there is a tracking failure or even in cases where you haven’t deployed your BAM activities, but your solution is trying to insert BAM data. In earlier version of BizTalk (2006 and 2006 R2) the DTA Purge and Archive SQL Server jobs didn’t clear this table periodically which resulted in unlimited growth of this table. Make sure you got the hot fix explained here http://support.microsoft.com/kb/977289

Monitor the size of databases
The size of the databases will vary from organisation to organisation depending on the volume of data processing. In any organisation having a bloated/large database will adversely effects the performance of your BizTalk environment. As a general rule of thumb, you can use the following numbers for guidance

BizTalkMsgboxDb: Not more than 5GB. However big your deployment is, your message box database should NOT go beyond this limit. In theory Message Box database only should hold transit data (aka inflight messages).  On a healthy environment all the processed message will either be moved to BizTalk tracking database or BAM database. Having lot of suspended instances will also bloat the size of the message box database, so periodically clear them out or better design your solution in a way you are not going to have too many suspended instances (unless otherwise there is a genuine unhanded exception scenario).

BizTalkDTADb, BAMPrimaryImportDB: Around 10 GB max.  This is again a finger in the air estimate. It’s better to keep the tracking data and BAM data within this limit. You can control this by setting the appropriate values for your DTA purging/archiving job and making sure you are moving your BAM data from BAMPrimaryImport table to BAMArchieve database. Also make sure your BAMArchive database is not bloated over a period of time. Do a hard purge after a set period like 3 or 6 months based on your business requirement.

The other databases like BizTalkMgmtDb, SSO, RulesEngine etc all store configuration data and they should be any bigger than 2GB.

Monitor transaction log sizes
The size of the BizTalk databases transaction log is controlled by the BizTalk backup job. By default the recovery model for the BizTalk databases is set to Full. If the transaction log is not backed up or truncated on a regular basis, the log files or files can fill up. So, please make sure BizTalk backup job is configured and running successfully. This job automatically backup the BizTalk databases including transaction log, and thus ensures the transaction log does not grow to an unmanageable size. The backup job should also be performed multiple times during the day as it’s the job that lets you recover your messages. The bigger the log file the more messages that could be lost.

It is not recommended to change the recovery model settings of the BizTalk databases. Changing this setting will put the BizTalk environment into a state where it may not be fully recoverable in the event of failure.

Not but the not the least the Backup BizTalk Server job is the only supported method to back up the BizTalk Server databases.

BizTalk 2010 Monitor BizTalk Server Job
If you are using BizTalk Server 2010, you can run the Monitor BizTalk Server SQL Agent job to identify any known issues in Management, Message Box, or DTA databases. The job is created when you configure a BizTalk group in BizTalk Server Administration console or upgrade BizTalk from the previous version.

The Monitor BizTalk Server job scans for the following issues in Management, Message Box, and DTA databases:

  • Messages without any references
  • Messages without reference counts
  • Messages with reference count less than 0
  • Message references without spool rows
  • Message references without instances
  • Instance state without instances
  • Instance subscriptions without corresponding instances
  • Orphaned DTA service instances
  • Orphaned DTA service instance exceptions
  • TDDS is not running on any host instance when global tracking option is enabled.

The Monitor BizTalk Server job is configured and automated to run once in a week. Since the job is computationally intensive, it’s recommended you to schedule it during downtime/low traffic.

The job fails if it encounters any issues; error string contains the number of issues found. Else, it runs successfully. You can see the details in the job history. If you run the job with Administrator privileges, error string will be logged to Event Viewer also (along with the job history).

Ad-hoc Full backup
It may be required once in a while to force a full database backup. The BizTalkMgmtDb.dbo.sp_ForceFullBackup stored procedure can be used to force a full backup of the data and log files. Execute this stored procedure, and then execute the Backup BizTalk Server SQL Agent job.

Cleanup all the data in test environment
DO NOT do this in PRODUCTION

When you are managing test environment (especially performance testing) it may be required to clean up BizTalkMsgBoxDb and BizTalkDTADb. When I say clean up, completely wipe out all the data, hence the bold warning.

BizTalkMsgboxDb
1.    Copy the Msgbox_cleanup_logic.sql script from Drive:\Program Files\Microsoft BizTalk 200x\schema to the SQL Server.
2.    Execute this SQL script against the BizTalkMsgBoxDb database to update the bts_CleanupMsgbox stored procedure.
3.    Stop all BizTalk hosts, services, and custom isolated adapters. If you use HTTP or the SOAP adapter, restart the IIS services.
4.    Execute the bts_CleanupMsgbox stored procedure on all the BizTalkMsgBoxDb databases.
5.    Restart all host instances and BizTalk Server services.

BizTalkDTADb
1.    Back up all BizTalk databases.
2.    Execute the dtasp_CleanHMData stored procedure. Only use this option if the BizTalkDTADb database contains many incomplete instances that must be removed.

To do this, follow these steps:
a.    Stop all BizTalk hosts, services, and custom isolated adapters. If you use HTTP or the SOAP adapter, restart the IIS services.
b.    Execute the dtasp_CleanHMData stored procedure on the BizTalkDTADb database.
c.    Restart all hosts and BizTalk Server services.

Nandri!
Saravana

Windows Azure: Giving me money back :)

Windows Azure: Giving me money back :)

The Azure team has been busy and what a nice email for a Friday.

So that means no inbound charges (ServiceBus could be the exception) and they’ve just
dropped the outbound charges.

Bewdy!

—– snip —–

Dear
Customer,

We are pleased to announce, effective today, that we are reducing our price to you
for

Windows Azure Storage from $0.15 per GB to $0.14 per GB stored per month.

You will see this price decrease on your next invoice.

Today’s price reduction is part of our commitment to realize cloud efficiencies through
economies of scale and

share these cost savings with our valued customers. We appreciate your continued interest
in the Windows Azure platform.

Windows Azure Platform Team


Blog Post by: Mick Badran