How to get more out of your Dynamics CRM Server

The CRM web service has a cruisy job really, it has single create, update, delete operations, most of the time your grunty server out the back will be idling.

 

Recently on a project we needed to simultaneously create 200+ records per transaction, unfortunately there is no bulk create.

The quickest way is to put the 8 idling cores into good use using the ThreadPool.QueueUserWorkItem method.

{ThreadPool.QueueUserWorkItem((o) =>
{
object[] state = (object[])o;
// execute crm web service calls here

}, new object[] { context, contact });

});

What to use take 6-8 seconds to create 200 records now completes within 2 seconds.

 

A little gotcha is if you’re using CredentialCache.DefaultNetworkCredentials, it will give you a 401 unauthorized error; please make sure you impersonate the multiple threads correctly.

Refer to http://msdn.microsoft.com/en-us/library/ff647404.aspx and http://www.yeyan.cn/WebDesign/ExecutionContextImpersonationNet.aspx for more information about impersonation.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: