Need help to resolve lengthy workflow & timeout

I’ve got a workflow in place that’s timing out… sometimes. :sweat_smile: I’ve followed a number of suggestions on this side and broke down the workflow into custom events which are triggered from the main parent workflow.

The workflow times out sometimes, but not all of the time. When it times out, it fails navigating to the next page, but the data seemed to have been handled properly.

The whole workflow (would be great if I could paste the log here) is just under 5 minutes.

What surprises me when I read the log is that actions seem to be handled sequentially (whereas it’s my understanding that actions that do not depend on the result of the previous action should be handled simultaneously to speed up the app.

To give you some idea of what this workflow is doing:

  1. it’s initiating a game session, where it copies a number of card things and assigns those to the game session.
  2. It also deals 6 cards (changing ownership variable on these cards) to the current user.
  3. It also changes some variables here and there such as game and player status, and creates a log of game initiation events.
  4. It finally goes to the actual game screen.

The biggest part of the workflow (time and data wise) is number 1.

I’ve set this workflow as a custom event:

This event is triggered from the parent workflow:

About this workflow:
There are 3 types of cards. A number N of cards is drawn from the master deck (108 cards marked as template, from which the workflow copies the cards), where N depends on the number of players. In this example case, there are 3 players so 14 cards of each type, hence 42 cards in total.

I would expect that the three steps “Get Influence Cards” to “Get Building Cards” would be done simultaneously. However, the log shows they’re done sequentially. :thinking:

(Side question: does the timestamp on the log refer to the start or end time of the action?)

Now, am I doing this right? Is this a case where I should move the workflow to the back end as an API workflow? How can I improve the speed and stability of this workflow? Is there anything else I can do?

Need some coaching please. Thanks.

I’ve been playing around with this few days and tried to fix things to no avail: the workflow is about 4 minutes long and there’s a Workflow error - Operation timed out – app too busy message in the logs (not always showing as an alert for some reason that’s beyond me).

Few changes I tried:

  1. In the post above, I realized I was copying the card templates that contained the pictures of the cards. So I thought this would probably may the copying of template cards heavy, and so I modified the architecture, now using data-light card things, that link to a master template with an image. So that master template isn’t handled during the copy action.

  2. I modified values to each three type of cards after merging them. I though perhaps that changing these values in between batches, handling smaller size sets each time, would speed up things.

  3. I tried doing this with an API workflow—but that was even slower than ever.

So I’m not quite sure to understand what’s causing the sloth here. :thinking:

Also I noticed how in the logs the “button pressed” event is repeated several times in the logs, as if the button was pressed repeatedly (which it wasn’t). What’s up with that? :open_mouth:

I am reluctant in marking this as a solution, as it’s not what I wished the app would do, but it’s a workaround and so I thought I’d be sharing.

I am simulating a card game and after entering a “lobby”, once all players are in, there’s a “start” button for the host to initiate the game. This would take a list of 108 card templates, copy them for this game session, and out of that separate the three types of cards to remove a number of them depending on the number of players. In addition it would initiate a “transcript” of the game. However, this was taking 5 to 6 min and caused timeouts. Moving this process to the back-end was not a solution because the game has to be setup right now as the users want to play, and the API workflows take even more their time.

So instead I went and restructured the data architecture and logic of the app.

  1. Pre-build a limited set of cards (example 10 sets).
  2. Moved a couple of tasks to earlier stages:
    • Group sets under a “deck” thing as a list value.
    • Assign the deck to the game and vice versa as soon as the game is created.
    • Assign players to the game as soon as they join the lobby.
  3. Upon starting the game, the workflow fetches the deck from the game and finds cards of each time to “deactivate” them with a yes/no value, then shuffle the deck by randomizing its card list.

This makes the workflow do its job within a minute and that’s much more acceptable.

I’m still a little disappointed that Bubble isn’t more powerful than this :frowning: : but perhaps I’ll see some positive side to my new architecture soon :thinking: :