Multi-threading solution(s) to process intensive problem

Multi-threading solution(s) to process intensive problem

Hello everyone,

I am new to OutSystem and I am looking for an elegant solution to my particular problem.
I am running an OutSystems Process that executes a SQL-heavy statement that calculates and fetches a pricing table for a particular customer. My current solution is acceptable for a single customer use but leaves much to be desired when running for multiple customers.

Here are a couple of solutions that came to mind:

- Write my own extension which splits each unique Process to a single thread.
- Use a Timer to run and execute asynchronous tasks

My questions are: Can I pass a Process as a parameter to be used in a thread? Or do I need something more specific?

How do I schedule a Timer to run upon request?

Feel free to share your ideas and input.

Kind regards,

Hello Ricardo,

Without having more detailed context, I would say that you can tackle this problem using 2 concurrent approaches:

1) First and foremost, optimize the heavy statement. Surely there must be a way to reduce the load and the time it takes to calculate those values. Either optimizing the query, or add additional entities and attributes to hold pre-calculated values (like cubes and data set aggregation).

2) Second, if you really have the need to run multiple concurrent threads for the same calculations, timers won't be able to help up, as the same timer can only run once instance at a time. But you can do this with BPT Processes, if the time it takes to run the calculations is less then 5 minutes. BPT Processes instances can run in parallel, up to 5 per front-end server by default. Although this might help you for a short number of concurrent requests, it will not scale for a larger number of customers, unless the logic that takes too long runs asynchrounsly using web services, and the BPT Processes triggers the calculation launch and pools for the calculation ending, all using web services (SOAP or REST), which will also solve the problem of the 5 minutes execution time.

Again, this is from the top of my head without a depper analysis of the requirements you're facing.

Hope this helps.

Hello Miguel,

Thanks for your elaborated response. With regards to your suggestions:

1) There are some optimisations to be had but they are minor. I forgot to mention that I already fetch 'relevant' data for customers when launching the app. 

2) I really wanted to atempt a threaded approach, but I manage to get the desired performance by using BPT processes. The concrete solution was running a Process that scheduled and fired of my calculation query. 

I do feel that this would have been a great excercise, but I am happy with the result.

Thanks again for your input Miguel.

Kind regards,