How to improve MSMQ disk performance

There are a number of areas that affect MSMQ performance (memory, CPU, network) but for this post I'll just concentrate on disk throughput.

MSMQ uses a lot of disk I/O when you are requesting transactional or recoverable messaging. Not only do the messages have to be written to disk (to survive a server shutdown, for example) but also the sequencing information used to keep transactional messages in order needs to be persisted.

The Storage tab on Message Queuing Properties shows how these areas are divided up:

So by default everything goes to the same physical location but you can split them up. In an ideal world, each folder would be located on a dedicated disk with its own disk controller for optimal throughput but this isn't usually going to be practical and in most cases is probably going to be overkill anyway. A single dedicated disk (and not just a partition on the main disk) should do - make sure it isn't being use for anything else like the pagefile.

How To Optimize MSMQ Performance 

To dig deeper into what goes into which folder, have a look at

Interpreting file names in the Storage directory

Message files folder

  • Contains the LQS subdirectory (the location for queue definition files)
  • Contains files with an .MQ extension representing memory-mapped files in which messages are stored.
    The .mq file name extension will be prefixed with a letter representing the type of messages it is tracking: 

R - Express messages (Note that express messages are normally held in RAM, not disk. This file is used when there is no more available RAM.) 
P - Persistent (recoverable) messages; transactional messages are, by definition, recoverable. 
J - Journal messages  

  • Disk I/O is directly related to the rate at which messages arrive and are processed.

Message logger folder

  • Contains files with an .MQ extension representing memory-mapped files in which messages are stored.
    The .mq file name extension will be prefixed with a letter representing the type of messages it is tracking: 

L - Indexing bitmap for interpreting the journal or recoverable files.

  • Disk I/O is directly related to the rate at which messages arrive and are processed.

Transaction logger folder

  • The QMLog file is a history of transactional message processing.
  • The state of receiving ordered messages and the state of all active transactions is periodically saved to the following files (respectively):
    • MQInSeqs.lg1
    • MQInSeqs.lg2
    • MQTrans.lg1
    • MQTrans.lg2
  • Disk I/O is related to the number of clients sending/receiving transactional messages. Each client requires a record in the MQInSeqs log files so if there are thousands of clients then MQInSeqs.lg1 and MQInSeqs.lg2 can get VERY large. Large files take a while to be updated so when MSMQ is flushing transactional state to disk there will be a suspension of message processing until this completes. Some customers have seen MSMQ pause for several minutes when this happens which is documented here:

You may encounter a slow performance issue that causes any program to stop responding for several minutes 

along with some hotfixes to make this process more disk-friendly.