web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to reduce the time to create the organisation service for the first time regards to WCF service?

(0) ShareShare
ReportReport
Posted on by 592

We are using WCF service to connect the organisation service. I have a requirement where each transaction should complete within 5 to 6 seconds . When put a trace I can see that first transaction for creating organisation service is taking more time.  After that I can see the transactions are taking very less time as because of may CRM is catching the organisation service.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    imayur Profile Picture
    630 on at

    Hi,

    You will need to create a separate class for Organization Service Connection and it should singleton. Create first instance when application bootstraps and as it is singleton only one instance will be created. This will reduce the time for creating Organization Service connection every time and for the first request.

    And it will be good if you set your WCF's  InstanceContextMode to Single.

  • Suggested answer
    Syed Ibrahim Profile Picture
    6,257 on at

    Using OrganizationServiceProxy will give you better performance for your custom applications instead of OrganizationService for your operations. Please follow the best practice to follow more to fine tune it.

    msdn.microsoft.com/.../gg509027.aspx;MSPPError=-2147217396

    hope this helps

  • MS CRM DYNAMICS Profile Picture
    592 on at

    Thanks Mayur,

    Connection and it should singleton ------I am using PerCall  service with keeping the connection object in static variable ,as static variable persist data in multiple service calls and  the same connection will be shared with multiple users .

    InstanceContextMode------  I have added PerCall  as multiple users will access the service with different data .

    Static variable will flush when IIS will reset and that time I need to create the organsiation service again and that is taking time , I need to decrease the time.

  • MS CRM DYNAMICS Profile Picture
    592 on at

    Thanks Syed,

     

    I will check the same.

  • Suggested answer
    imayur Profile Picture
    630 on at

    Hi,

    Addition to my previous reply you can initiate singleton instance in auto start the WCF service in IIS(please refer below link for this to configure, hope you are not below IIS 7.5). This will instantiate your org service instance when application starts in app pool. 

    probably you need to instantiate singleton in Preload method inside PreWarmCache class instead of App_start of Global.asax.

    Please refer below  link for Auto starting WCF app

    Autostart app in IIS

    Please let me know your observations once you done this. 

  • Suggested answer
    imayur Profile Picture
    630 on at

    Here is the detailed and verified solution for Bootstrapping  application in on start of application pool


    Note: This approach requires minimum IIS 7.5 and .NET 4 and  managedPipelineMode="Integrated" for Application Pool


    Add below class in WCF Service
    -----------------------------------------------------------------------------------------------------
    namespace MyWCFService // add this class in WCF Service
    {
    public class MyWCFServiceWarmup : System.Web.Hosting.IProcessHostPreloadClient
    {
    public void Preload(string[] parameters)
    {
    CRMService service = CRMService.GetService(); //crm service singleton initialzation
    }
    }
    }

    -----------------------------------------------------------------------------------------------------

    Open Command Prompt and write below Commands

    cd c:\windows\system32\inetsrv\config


    notepad applicationHost.config

    ----------------------------------------------------
    Edit applicationHost.config

    1. Find your Application Pool Entry under Configurations
    2. Add managed startMode="AlwaysRunning" refer below example
    ------------------------------------------------------------------------------------------------------

    <applicationPools>

    <add name="MyWCFServicePool" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" startMode="AlwaysRunning">
    <processModel identityType="NetworkService" />
    </add>
    </applicationPools>

    3. Find your Application under sites -> site
    4. Add serviceAutoStartEnabled="true" serviceAutoStartProvider="MyWCFServicePreLoad" refer below example
    -------------------------------------------------------------------------------------------------------
    <sites>
    <site name="MyWCFService" id="12" serverAutoStart="true">
    <application path="/" applicationPool="MyWCFServicePool" serviceAutoStartEnabled="true" serviceAutoStartProvider="MyWCFServicePreLoad">
    <virtualDirectory path="/" physicalPath="C:\Services\MyWCFService" />
    </application>
    </site>
    </sites>


    5. Then Add below tag after </sites> .
    ---------------------------------------------------------------------------------------------------------

    <serviceAutoStartProviders>
    <add name="MyWCFServicePreLoad" type="MyWCFService.MyWCFServiceWarmup, MyWCFService" />
    </serviceAutoStartProviders>

    ---------------------------------------------------------------------------------------------------------

    6. Save applicationHost.config

    This will initiate first instance Singleton class when Application Pool starts instead of first request hit.

    Restart WCF Service and then Application Pool in IIS.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans