Can I have 1,000s of MSMQ queues?
"Can I have 1,000s of MSMQ queues?" Yes, of course you can.
"Is it a good idea to?" Maybe not.
The queues themselves do not take up many resources:
- In memory - each ACTIVE queue is about 400 bytes (over half of which is kernel memory).
- On disk - each queue has a configuration file (in the \msmq\storage\lqs directory) and these are only 1-2kb each.
So a thousand queues - all containing a single message, for argument's sake - are not going to be much of an overhead on an MSMQ machine.
The problem may come when you restart MSMQ as the service has to refresh the contents of the \msmq\storage\lqs directory before it completes startup.
- Private queues - each configuration file has to be read and the data processed.
- Public queues - the configuration file is deleted and recreated on startup because it is only a cached version of the queue properties (which are stored in Active Directory) to be used by MSMQ in off-line mode. The cached information needs to be refreshed with an LDAP query to a local domain controller and that sort of activity is not cheap.
So, if you must have 1,000s of queues then it is a good idea to avoid Public queues because of the delay in startup.
Other things to take into account:
- Computer Management will take FOREVER to display 1,000s of queues so you will need to invent your own custom queue management software or processes.
- Operations like MQGetQueueProperties may be slow.
Note - If you also use Triggers, there is an additional performance hit on startup as the trigger service creates msmqtriggerServiceStatus.log. If all your queues each have a trigger then the startup time can be doubled.