camunda / camunda-bpm-platform

Flexible framework for workflow and decision automation with BPMN and DMN. Integration with Quarkus, Spring, Spring Boot, CDI.
https://camunda.com/
Apache License 2.0
4.11k stars 1.55k forks source link

Deployment performance slow when process contains message events #3088

Closed kalekhin closed 1 year ago

kalekhin commented 1 year ago

User Story (Required on creation)

When the application is launched, the engine performs a deployment for too long if there are many intermediate events in the database, similar to the start event of the process.

Functional Requirements (Required before implementation)

Intermediate events should not interfere with the execution of the deployment

Technical Requirements (Required before implementation)

It is necessary to filter intermediate events at the sql query level, not at the application level

Limitations of Scope

Hints

In this method, on the specified line during deployment, the engine selects all event subscriptions with same name as start event of new process deployment, including subscriptions from intermediate events. Which, with a large number of processes with intermediate start events, leads to a long start freeze. Over time, this process degrades more and more!

https://github.com/camunda/camunda-bpm-platform/blob/aea7c65c5038e03793feb1ea96705974c5683e95/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/deployer/BpmnDeployer.java#L315

Instead of using a query with id = selectEventSubscriptionsByNameAndTenantId, you need to use the selectMessageStartEventSubscriptionByNameAndTenantId query.

If you use this query option, then the subsequent filtering on the line 335 can also be omitted.

https://github.com/camunda/camunda-bpm-platform/blob/aea7c65c5038e03793feb1ea96705974c5683e95/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/deployer/BpmnDeployer.java#L335

The case is reproduced if the starting message event in new deployment has the same message name as the intermediate message event.

Links

Breakdown

Dev2QA handover

tasso94 commented 1 year ago

Hi @kalekhin,

Please adjust your ticket description by incorporating our feature request ticket template.

You can find it here: https://raw.githubusercontent.com/camunda/camunda-bpm-platform/master/.github/ISSUE_TEMPLATE/feature_request.md

Best, Tassilo

kalekhin commented 1 year ago

Hi @kalekhin,

Please adjust your ticket description by incorporating our feature request ticket template.

You can find it here: https://raw.githubusercontent.com/camunda/camunda-bpm-platform/master/.github/ISSUE_TEMPLATE/feature_request.md

Best, Tassilo

Done! Review, pls.

tasso94 commented 1 year ago

Hi @kalekhin,

To have evidence that your suggestion improves the performance, please run both queries against your database, generate query plans, and share them with us. Query plans usually allow understanding better why the performance improves.

Best, Tassilo

kalekhin commented 1 year ago

Hi @kalekhin,

To have evidence that your suggestion improves the performance, please run both queries against your database, generate query plans, and share them with us. Query plans usually allow understanding better why the performance improves.

Best, Tassilo

Hi! Obviously, performance increases due to a significantly smaller sample size.

160+k rows vs. 2-3 (not thousands) rows.

But if it doesn't seem obvious that I will be able to do it on Monday during my working hours.

tasso94 commented 1 year ago

Hi @kalekhin,

Please share the query plans.

Best, Tassilo

kalekhin commented 1 year ago

I'm sorry, I fixed it locally by overriding BpmnDeployer and forgot about the current topic :)

From testing env (much smaller sample size than in production)

image image

tasso94 commented 1 year ago

Hi @kalekhin,

Your shared numbers look promising.

I'll have a look at how we can make use of the cheaper query and get back to you with my insights.

Stay tuned!

Best, Tassilo

tasso94 commented 1 year ago

Hi @yanavasileva,

Could you have a look at my PR #3109 and double-check if this fix is feasible and if I'm not overlooking anything?

Best, Tassilo

tasso94 commented 1 year ago

Hi @kalekhin,

I just merged the performance improvement with our master branch.

Thanks again for raising this issue.

Best, Tassilo