PL 400 : optimize plug-in performance (Create a plug-in)

Microsoft Dataverse has a plugin power tool that gives the ability to enhance the behavior of the platform. Microsoft recommends using this tool when all other out of the box functionalities do not work to meet business requirements. A well written plugin gives Optima performance but a poorly written plugin environment can have a significant impact on performance, so it is common advice for developers to write optimized code.

Optimization is the set of best practices and standards that developers use to make software code run efficiently.


In customer-relationship applications, poor performance can lead to even bigger problems. Instead of helping our customers do business with the company and build a competitive advantage, the software application frustrates  them. They may try to reload the page, causing even more problems and delays for the application. Application performance can directly affect company metrics such as employee performance and productivity.

I collected some best practices and standards for optimizing plugin performance which are below:

Asynchronous or Synchronous plugin:

Plugin can set up in synchronous or asynchronous mode. Synchronous mode starts the execution of the plugin when the event is fired and blocks the CRM application process until the executed method finishes. Generally, this option is not recommended for long running process. Asynchronous mode releases the application process, and the user can continue working while the code is executed.

Synchronous Mode:

If the developer intends to register plugins for synchronous execution, it is recommended that it design them to complete their operation in less than 2 seconds. It is best to reduce the processing time in the plugin to maintain client interaction with the same organization service that executes the plugin.

Infinite loop consideration:

An infinite loop can be dangerous because code can get stuck and block functionality. This can consume the entire CPU usage and clog other blocks of code. It always needs to verify infinite loop of plugin  and uses context depth to restrict it.

External Service:
If we use any external service in the plugin then don't forget to close the connection and don't use heavy object as it may cause the plugin to slow down.

Late Binding vs Early Binding:
Use the Entity Class (Late Binding) result is slightly better performance than the early bound entity types.

Time Limit:
A plugin registered for synchronous or asynchronous execution in restricted to complete its execution in a two minute time limit.

Stateless Condition:

Plugin execute until they are completed, so it must be written to be stateless where no- in memory data is persisted.

Permission/Privilege:

The plugin runs in the administrator context, we need to be aware that this code can access information that the logged on user does not have access to. 

Sequential GUID :

Let the system assign the GUID(Id) automatically instead of creating it manually. This suggestion allows the plugin to take advantage of sequential GUIDs, which will provide SQL performance.


Comments

Popular posts from this blog

PCF vs. Web Resources: Choosing the Right Extensibility Tool for Dataverse

Is Debt Prosperity or Trap?

Exam PL-400: Microsoft Power Platform Developer