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)

The first plugin's execution takes a long time

(0) ShareShare
ReportReport
Posted on by

I have a plugin that updates the opportunity product quantity after a bundle is added to opportunity. The first time that the user adds a bundle to opportunity, the plugin's execution takes long time, after this, the time execution is normal. After a short period of user inactivity working with opportunity products the plugin execution takes long time again.

Any idea what is causing this delay during the first plugin execution?

Notice that all plugin's executions are successful. CRM Online 2016

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    I see this all the time. When a plugin assembly isn't being used CRM unloads it to free up resources. When it's needed again, it spins it up. this is why it's slow at first and after long inactivity, but quick otherwise. There's not much you can do about it besides trying to keep the plugin life alive but I wouldn't recommend that.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

  • clajar Profile Picture
    on at

    Hi Aiden.

    Thanks for your quick answer.

    Any special reason because you don't recommend keep the plugin life alive?

  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    In general, you wouldn't want to keep your assembly alive because it'll prevent CRM from releasing the resources being used. If you have a simple plugin that doesn't do much it may not be a big deal, but with more functionality and larger assemblies it could start to be an issue.  There's probably more benefits from the plugin being cleaned up too - if there are any inefficiencies in your code that grow over time, this will get cleared out instead of piling up until it crashed.

    Thanks,

     Aiden

  • clajar Profile Picture
    on at

    Thanks Aiden

  • jbinaz Profile Picture
    20 on at

    So how would you keep a plugin alive? Settings in IIS if you're running on-premise? I just discovered I have the same issue: after a period of inactivity, saving a custom entity record is taking ~2 minutes the first time. If I immediately create a second record, it takes < 5 seconds. That's a huge difference - one my customer can live with, and one that will cause complaints every time.

  • Aiden Kaskela Profile Picture
    19,696 on at

    Hi,

    I'm not positive but I can think of a few things to try. Essentially what you want to do is keep making calls to your plugin so CRM doesn't dump it. A few ways you could try it (and need to test of course):

    1) Create a new dummy keep-alive entity. You'd create an async workflow that runs on Create of your entity. When KeepAlive is created, the workflow runs, waits 2 minutes or something, then calls a custom workflow step in your plugin assembly. Your custom workflow step would create a new KeepAlive kicking off the process again. This will be fragile though, because if one workflow fails then you'll have to restart it manually.

    2) Add a plugin step to things that get accessed frequently - RetrieveMultiple, or Retrieve of a contact and account. If people are using CRM but not triggering plugins for your assembly, this should help keep the plugin alive longer. It'll still drop off overnight if nobody is on the system though.

    3) Have an external service keep alive your plugin. This is like #1, but you have a windows service or Azure service that hits CRM every minute or two and triggers something for the plugin to do. It's more durable than #1 because you control when the service runs, and it's nice to not have to create those workflow, but you have to manage another service running outside of CRM.

    Hope this helps!

     Aiden

  • jbinaz Profile Picture
    20 on at

    Thanks for the reply. I'd had a thought of artificially creating something but didn't think it would really fly with the customer and it feels like a workaround. Might be the only way, though. I wish there was documentation on how long before stuff times out, along with a way to specify to keep it alive in some sort of setting. I'm dealing with online, so I understand MS has to balance resources but it's frustrating when something that should take <5 seconds takes almost two minutes. Obviously optimization is a good idea, but when everything is functioning and it doesn't take too long, you figure you don't need to optimize too much.

    I have to wonder if there's something that changed recently as far as their data center config and how it handles plugins, because our customer just noticed this and this thread is brand new, making me think that it's fairly recent.

    Thanks again.

  • Adrian Tedeschi Profile Picture
    on at

    Hi Aiden, I'm experimenting this same issue. The client complains as sometimes the system takes >30 seconds to complete a simple save operation (because this issue about plugin taking a long time).

    I can't see how can I explain the client this situation, kind of making the plugin unusable, at least in sync mode.

    How can we use plugins as extension of default CRM behavior if it produces this effect? The same issue happens if I use a sync workflow instead a plugin? I can't imagine how can users wait so long, even if the user is the first in the morning

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