Max Schilling
Max Schilling

Reputation: 2931

mqsvc.exe pegs cpu at full usage when deploying nservicebus to production

When I deployed my site that uses nservice to a new production box, it was unusably slow...

After some debugging I discovered that mqsvc.exe was taking up 50% of the CPU usage and the other 50% was being taken up by w3wp.exe

I found this post here: http://geekswithblogs.net/michaelstephenson/archive/2010/05/07/139717.aspx

which recommended the following:

  • Make sure you set the windows service for NserviceBus Generic Host to the right credentials

  • Make sure you have the queue set with the right permissions

  • Make sure you turn on the right logging configuration in NServiceBus

So I figured the issue was something related to permissions, but even after trying to set the permissions correctly (I thought) I still wasn't able to resolve the issue.

Upvotes: 1

Views: 1371

Answers (2)

Max Schilling
Max Schilling

Reputation: 2931

The issue did end up being that the website needed to be granted explicit permissions to the queues.

I found a number of resources online telling me this, but I still had to spend a good amount of time monkeying around with exactly WHICH account needed access... turned out that since my application pools were set to run as ApplicationPoolIdentity, I need to grant the account permissions by adding the following account to the NServiceBus queue:

IIS AppPool\{APP POOL NAME}

I granted full access rights, though I'm sure you could refine that a bit if you needed to.

Upvotes: 3

David Boike
David Boike

Reputation: 18645

If you allow NServiceBus to create its own queues, then it will create them with the correct permissions it needs.

The problem comes in when you set up a web application, and then the queues are created, and then the identity the application runs under changes. Then you get exactly this problem. NServiceBus tries to check the queue for a message, it does not have access to do so, so it immediately retries over and over, and you spike the processor.

The fix: Delete the queue. Restart the web application. NServiceBus takes over.

Edit: As noted in the comments, NServiceBus 3.x doesn't invoke the installers by default, which means queues are not automatically created in production unless you ask it to. See the documentation page on Installers for more detail.

For a web application (or any other situation where you're not using NServiceBus.Host) you can invoke the installers as part of the fluent config. There is a full example in the NServiceBus download, but here is a link to the relevant file on GitHub.

Upvotes: 3

Related Questions