Tuning the performance of your WF rules
Someone asked a question on the WF forum today about tuning the performance of his rules.
Basically the WF Rules Engine is single threaded and we dont expose any knobs for you to tweak the performance of the rules in WF V1. One way for you to improve the performance of your rules is by really thinking about the design of your rules.
One question to ask is - do I really need forward chaining? You can control whether or not by tweaking with the RuleChainingBehavior. Basically we will keep re-evaluating higher priority rules if actions of other lower priority rules actions updated the fields used in the high priority rule's condition - if you dont think that's going to change the results of your rule evaluation, you could yourself order and prioritize rules in a way that you explicitly disable chaining and optimise how your rule set runs.
One thing that can help you with your analysis is rules tracing - this is enabled by the following addition to your config file.
<system.diagnostics>
<switches>
<add name="System.Workflow.Activities.Rules" value="All" />
</switches>
</system.diagnostics>
Another way you can improve the performance is to write a custom PolicyActivity by deriving from it and then caching the RuleExecution and RuleValidation so that if the WF has other YourCustomPolicy activities which use the same RuleSet, then you can use the cached version and get better performance.
Comments
Anonymous
October 16, 2006
I posted this on my blog today after we saw a question about this on the WF MSDN forums. In future releasesAnonymous
October 17, 2006
To follow up on my post from yesterday on Tuning the performance of your WF Rules , here is some code