Performance Monitor has trouble showing over 4GB of MSMQ messages.

I have been testing my 64-bit MSMQ 3.0 server by chucking 1,000s of large messages at it to see how well it responds. I did have Performance Monitor running, showing “Total messages in all queues” and “Total bytes in all queues” for the MSMQ service. I would come back to the screen every now and then and think – “strange, there’s less messages than there was 10 minutes ago.” – but not having the time to investigate, I shrugged and left it.

Today I came to purge the queue and saw the attached Performance Monitor graph (image stitched together from a couple of screenshots).

Reproduction of problem

As you can see, the Performance Monitor counters magically found more messages to count every time 4GBs of messages were purged. There was no other MSMQ activity – I don’t have any magic app that could deliver 4GB of messages in one perfmon tick!

I checked the Storage directory and there were 19GB of files. The messages were just over 1MB in size so I am expecting an amount of empty space in the *.MQ files (maybe 20% ?). From the Performance Monitor graph I must have had around 12GB-16GB of messages (I may have missed a peak when collecting screenshots) but only 4GB would display at any one time.

When ever it reached 4GB it must have reset to 0 and climbed up to the next 4GB step. This must have been why I could see less messages than 10 minutes earlier. This also explains why I couldn’t send more messages after it appeared that I had reached 4GB. In reality I must have had 8GB of messages and reached the system quota but perfmon only showed 4GB. To check this I removed the quota, rebooted, and messages flew again.

The root cause is as follows:

Performance counters in Windows 2003 are all 32-bit counters (type PERF_COUNTER_RAWCOUNT/PERF_COUNTER_COUNTER) as opposed to 64-bit counter (PERF_COUNTER_LARGE_RAWCOUNT/PERF_COUNTER_BULK_COUNT). Hence these counters will wrap-around after 4 GB. On Windows Vista, all the counters have been changed to 64-bit and hence this problem should not appear there.

Bottom line – what are you doing with more than 4GB stored in MSMQ? Use SQL Server instead!

Comments (3)

  1. Ravi says:

    Hi I have a question regarding performance of MSMQ. I want to know how the performace changes if the size of the queue is large like 4GB.

  2. MSDNArchive says:

    It depends what performance you are looking at.

    If these are recoverable messages then startup will take a while as MSMQ processes all the messages to index them. It is also important to know the size of the individual messages – 1,000 4MB messages are much easier to index than 1,000,000 4KB messages but both take up 4GB of space.

    A large queue is only a problem if your application has to search through all the messages for what it wants instead of just taking the first one from the top of the queue.

    If you are concerned about volume of messages then you need to look at the system as a whole. A queue does not exist as a separate area – all messages are stored in the same space and the queue is just a property of the message. So review what the total volume of messages is before worrying about queues.

    MSMQ tries to store messages in virtual memory but this is a limited size (mayber 1.5GB free) so excess messages will be left on disk. You therefore start to see more disk activity when you go over 1.5GB of messages but this depends greatly on how quickly messages arrive and get processed.

    In summary, there is no simple answer to your question.


    John Breakwell