Performance Issue on Call Activity calls

Hi,
I have been developing critical flows which has limited time to complete.
When I troubleshoot the logs, I see it loses some time during the db operations.
I use PostgreSql and this is only test database with no data, and I let spring to create schema so its created by default indexes, etc.
If you check below logs, it waits around 450 milliseconds for only a DELETE operation.
I see it loses around 1 second to reach only the start event every time its gets into a subflow (Call Activity).
This time passes in the process engine with db operations.

What can I to improve this ?

2021-03-23/08:13:04.691 [camundaTaskExecutor-2] DEBUG org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution:143 - ==> Preparing: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
2021-03-23/08:13:04.691 [camundaTaskExecutor-2] DEBUG org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution:143 - ==> Parameters: 719c83f5-8b96-11eb-9e8c-782b46057658(String), 1(Integer)
2021-03-23/08:13:04.691 [camundaTaskExecutor-2] DEBUG org.camunda.bpm.engine.persistence:118 - ENGINE-03009 SQL operation: ‘DELETE’; Entity: ‘ExecutionEntity[id=7176ac73-8b96-11eb-9e8c-782b46057658]’
2021-03-23/08:13:04.691 [camundaTaskExecutor-2] DEBUG org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution:143 - ==> Parameters: 7176ac73-8b96-11eb-9e8c-782b46057658(String), 1(Integer)
2021-03-23/08:13:05.148 [camundaTaskExecutor-2] DEBUG org.camunda.bpm.engine.jobexecutor:118 - ENGINE-14017 Notifying Job Executor of new job notifying job executor of new job
2021-03-23/08:13:05.148 [JobExecutor[org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor]] DEBUG org.camunda.bpm.engine.jobexecutor:118 - ENGINE-14012 Job acquisition thread woke up
2021-03-23/08:13:05.149 [JobExecutor[org.camunda.bpm.engine.spring.components.jobexecutor.SpringJobExecutor]] DEBUG org.camunda.bpm.engine.cmd:118 - ENGINE-13005 Starting command -------------------- AcquireJobsCmd ----------------------
2021-03-23/08:13:05.149 [camundaTaskExecutor-2] DEBUG org.camunda.bpm.engine.cmd:118 - ENGINE-13006 Finishing command -------------------- ExecuteJobsCmd ----------------------
2021-03-23/08:13:05.150 [camundaTaskExecutor-2] DEBUG org.camunda.bpm.engine.cmd:118 - ENGINE-13005 Starting command -------------------- SuccessfulJobListener ----------------------

When I start my flow, I see camunda runs 20 db queries in a second for just a single flow. (History and metric is even not enabled)

Thinking that I would expect a high traffic on the prod, this could result in 1000 tps which makes me worry about it.

I really hope to hear some advises to minimize the db transaction numbers.

For instance, can I disable incidents which I don’t think I would have any use cases ?
Can I override org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionManager.java to do extra caching because I don’t expect to deploy flows on the fly ? And I start camunda as springboot starter so I should have more options to customize how things work.

I finally found the issue after spending 3 days, and actually it was mentioned in the docs or blogs that
too many save points can result in performance issues. Save points increase the database interactions.

https://camunda.com/best-practices/dealing-with-problems-and-exceptions/#additional-save-points

It was a long time ago and I just forgot that I added asyncBeforeTrue for process definitions in bpmnparselistener.

import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener;
import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl;
import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl;
import org.camunda.bpm.engine.impl.util.xml.Element;
import org.camunda.bpm.engine.repository.ProcessDefinition;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class CustomBpmnParseListener extends AbstractBpmnParseListener implements BpmnParseListener {

	@Override
	public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEvent) {
		if (scope instanceof ProcessDefinition) {
			log.trace("Adding save point before Start Event '{}", startEvent.getId());
			startEvent.setAsyncBefore(true);
		}
	}
}

The main purpose adding this at the first place was to allow the start process method to return the process id immediately.

ProcessInstance p = runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey, parametersMap);

But this small change led camunda to interact with database so often because my flows has too many call activities which means too many processes start and end in one single go.

So basically, I removed startEvent.setAsyncBefore(true); to resolve the issue.

Hi @guvenc
I’m really happy that you managed to solve the problem and wanted to say thanks a lot for posting your solution, i’m sure it’ll help other people in the community experiencing the same problem.