Do you have a large user base Dynamics CRM deployment that is configured to send emails using the E-mail Router, but you continue to see performance problems or a backlog of pending emails?

When you are using the Dynamics CRM E-mail Router with hundreds or even thousands of users, backlogs can occur because the E-mail Router polls for emails in a round robin fashion. For example, by default, the E-mail Router will poll the first five users and the first 5 emails for each of those users. This will continue through all users before it gets back to the first users.

Problems can arise in the round robin when you have a large number of users and especially if you have users that are sending thousands of emails a day. These types of users can create a backlog. For example: 

If a market manager is sending on average 10,000 emails in an 8-hour day, which equals out to approximately 1250 per hour for just this user and an organization with two thousand users. The polling will continue through all users by polling five users and five emails for each of these users at a time. By the time the E-mail Router has gone through the two thousand users, the backlog for our market manager has decreased by only five, or in some cases, it has increased. In this case, you would see the router performing very slowly and a backlog of pending emails waiting to be sent from CRM. This also makes an impact on the SQL server due to the vast amount of queries that are being called for the 5 users and 5 emails for each of these users, as it tries to send the backlog of emails.

Now, the amount of users being polled during a single period can be increased; however, when working with hundreds or thousands of users, this has little overall impact on performance. You can also configure additional email providers in the EmailAgent.xml. Each provider will then contain a group of users that will be polled separately. This will increase performance, but again, with thousands of users, it may not be enough.

Having worked on a few of these performance cases, we have created a customer provider that no longer uses the round robin polling functionality. Instead of these user based queries, this will look directly into the organization for any pending emails on a first come-first serve basis.  Not only does this improve performance but is has a smaller impact on the SQL server.


That being said, there are some caveats to this. Currently, this custom provider will send any pending emails regardless of the user's setting to use CRM for Outlook or the E-mail Router. Therefore, this will send emails if people are configured for either option, but they will be sent with the E-mail Router.

In addition, it will not check if the Email Address for the User has been approved. It will send these emails regardless if the Email Address for the User has been approved or not. Finally, because the <ConfigUpdatePeriod> parameter needs to be set to 0 to prevent the custom provider information from being overwritten, the e-mail router will not check for new users who may have been added for incoming e-mail access or forward mailbox after this value is set. However, to overcome this potential issue, a custom outgoing provider can be created for the custom provider .dll, which will allow you to keep the <ConfigUpdatePeriod> parameter at its default value. This will be explained in a future blog.  

Changes to these caveats will be made to the custom provider .dlls in the future.

 

Implementation

In order to implement this customer provider, you will want to download the proper .dll from the Codeplex links below:

 

This link is for Update Rollup 11v2 down to Update Rollup 6:

https://customrouter.codeplex.com/downloads/get/627321

This link is for Update Rollup 12 and up.

https://customrouter.codeplex.com/downloads/get/627322

 

Once you have this downloaded, follow the steps below:

1. Go to Start | Run and type Services.msc. Stop the E-mail Router service and close the E-mail Router configuration wizard.

2. Place the new .dll file in the follow location: C:\Program Files\Microsoft CRM Email\Service

3. Navigate to C:\Program Files\Microsoft CRM Email\Service\EmailAgent.xml file and open this in Notepad. Change following properties:

a. Change "ConfigUpdatePeriod" to "0".

b. Replace "ProviderAssembly" and "ProviderClass" nodes in each of ProviderConfiguration node to following:

<ProviderAssembly>CustomOutgoingProvider.dll</ProviderAssembly>

<ProviderClass>CustomOutgoingProvider.CustomSmtpProvider</ProviderClass>

4. Save the changes

5. Start Email Router service