I got a problem with a business process I’m modelling right now and don’t know how to effecient solve it. Because of the complexity and internal information I’ll use a simplified process description:
Right now we have a process for ordered pizza. Within the process instances are all information regarding the ordered pizza itself (mainly the pizza type e.g.: Salami, Hawai, Magaritta…). We have many pizza orders during the lunchtime and got around 500 orders going. The management got in touch with me and asked me if I can extend our dashboard (external webfrontend) with statistics of currently opened orders.
For getting the data my solution would be using the REST endpoints like this:
- GET all process instances of the process
- foreach process instance GET the pizza type variable and display it
Right now my only concern is the performance of this. What happens if we got more process instances going? Is it best practice to do it like this or do I miss an rest endpoint, I could use instead to get all process variables more effeicient?
it depends, on what do you mean by “statistics”, but here are some thoughts from my side:
- take a look at this REST endpoints: https://docs.camunda.org/manual/7.9/reference/rest/variable-instance/
- if you have limited number of pizza types and you know all possible values of “pizza type” variable, you could iterate over these values and list process instances with corresponding pizza type (or call Get List Count request if you need only number of instances)
- if pizza type is immutable within one process instance, when starting the process instances, you can include pizza type in business key and then search by businessKey like ‘pizzaType%’
- If you need to show the list of process instances with variable value - you should consider paginating it (obvious, but still)
- you can go even further and check out these docs and consider using native queries or custom queries: https://docs.camunda.org/manual/7.9/user-guide/process-engine/process-engine-api/#native-queries and https://blog.camunda.com/post/2017/12/custom-queries/
If you’re more precise about what kind of statistics do you need, may be somebody has more insights