Backend workflows - Is there anything I'm doing wrong?

Hi bubblers,

I am getting a bit worried about how my apps behaves after scheduling some back-end workflows that start when page is loaded.

Here is how it goes:

  • I want the app to update the supplier spend every hour at page reload. The update should be done for suppliers associated with the company my user belongs to.

The supplier update is done this way:

In normal workflow screen:

  • I schedule the backend workflow if the last update was done more than 1 hour before.
  • I identify all the suppliers thru a Search for function
  • I count the number of suppliers to be used as a count parameter later in the backend workflow.
  • I identify the first supplier as being index=1

In the backend workflow screen
Step 1.
I calculate sum product for all POs of status 0, related to supplier with index=1
I calculate sum product for all POs of status 1, related to supplier with index=1
I calculate sum product for all POs of status 2, related to supplier with index=1
I update the relevant fields for the above 3 values

Step 2.
I calculate the sum of all the above 3 values, related to supplier with index=1
I update the relevant field for the total

Step 3.
Loop thru the backend workflow while index<count

Step 4.
Record supplier update field at user’s company level when index=count.

At this point I am talking about 160 suppliers but I am expecting more.

The workflows run like a charm if I don’t touch the app. Takes about 1 minute to update all and the user’s company field.

On the other hand, if by any chance, I refresh the page again before it ends, the workflow starts again since it did not manage yet to update the supplier_update field at the user’s company level. This is where the main problem is: if 2-3-4 workflows start (depending how many times the page is refreshed), the app becomes extremely slow or even unresponsive and all workflows time out. I also get an email from bubble that the app has reached its max capacity.

Is there any redundancy, any inefficient way I built this or am I just struggling with resources as I am only on a Personal (legacy) plan and I need to upgrade??

Ready to jump on a video call if anybody has the time to go thru this…

It’s quite hard to tell you anything useful without knowing your DB structure and approx estimations for it’s size.
As to the problem you’ve mentioned, you need to distinguish between moments when backend workflow is started and finished, so you can track upon page load if backend workflow has already been started.

But if your app hangs with 10 workflows running there’s something that definitely needs optimization.

I was thinking of the same thing related to the start/finish. I’ve done that and it does not run into issues anymore. I might set-up a cron job to do it automatically at a low volume period