elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
5.87k stars 1.06k forks source link

[PERF] Optimize Message Handling in `IWorkflowInbox` to Reduce Workflow Dispatch Latency #5241

Closed sfmskywalker closed 3 weeks ago

sfmskywalker commented 3 weeks ago

When initiating multiple dispatched workflows concurrently, there is a significant delay before all workflows are processed. This delay appears to stem from excessive messaging within the IWorkflowInbox service, which is tasked with broadcasting events to resume the DispatchWorkflow activity.

Issue Details:

Proposed Solution: To alleviate the processing delay and optimize system performance, we should modify the IWorkflowInbox service to conditionally send messages. Specifically, the service should check for the presence of relevant bookmarks in the database before issuing messages. This change aims to prevent the queue from being filled with redundant messages that do not contribute to workflow processing.

Expected Benefits:

This optimization should lead to a more responsive and efficient workflow dispatch mechanism, enhancing overall system performance.

glime-ai[bot] commented 3 weeks ago

To address the issue of significant delays when initiating multiple dispatched workflows concurrently due to excessive messaging within the IWorkflowInbox service, it is indeed necessary to optimize the dispatch mechanism. The proposed solution to modify the IWorkflowInbox service to conditionally send messages only when there are relevant bookmarks in the database is a valid approach. This would prevent the generation of unnecessary messages and reduce the load on the messaging infrastructure.

However, implementing this solution requires careful consideration of the workflow engine's internal mechanisms to ensure that no dispatched workflows are missed and that the system remains reliable. It may involve changes to the way bookmarks are managed and how messages are correlated with them.

Before proceeding with this optimization, it would be important to review the current implementation of the IWorkflowInbox service, the bookmark management system, and the messaging infrastructure to identify the best approach for conditional messaging. Additionally, thorough testing would be required to ensure that the changes do not introduce new issues or negatively impact existing workflows.

If you are looking for guidance on how to implement this change or if you need further assistance with the specifics of the Elsa Workflow system, please provide more details or clarify your requirements.

This comment was generated by Glime.