How to best run backend functions that take more than 30s?

Bubble limits server actions to 30 sec.

First question: Is it true that this limitation is for both, actions called from a page as well as actions called from a backend API workflow?

I have an application where several API calls made to third party services by the backend function means that the code takes longer than 30s to run.

Second question: I understand that using a separate backend is the only possible option to resolve this unless I can split that backend code into sub-actions?

Third question: Is Netlify a recommended option? Other options that you would recommend?

I believe so. There is a 5 minute timeout rule for all workflow series. I believe the 30 second rule you are referring to is specific to API calls.

Likely not 30 seconds for any one particular API call, but more than 30 seconds for all actions within the series of actions to complete, so you are really just looking at the 5 minute timeout rule for workflow series.

You can split it if you want and can come up with the most efficient way for your use case to split it and still pass the values to each split series if needed.

What is Netlify?

2 Likes

If you only need to run server side functions and you want to do it with code instead of netlify I would suggest cloudflare workers. It’s wonderful to work with. If I recall correctly http request time does not count towards billable time.

Netlify

2 Likes

Don’t the workers have 10ms/50ms CPU time limits? My main issue is the 30sec+ runtime of my code

Or do you mean since the wait time for external api is not counted the actual code run time would be 10ms or less?

50ms of actual computations, the wait for network request does not count. The unbound plan has longer maximum duration.
Of course this is just one of many many possibilities you have between having your own server and having just a managed function execution.

1 Like

You could use an external service like google cloud functions to run a long process. When it finishes it could call a backend workflow and you could process results.

You could have a table in your bubble app to help monitor these outbound/inbound calls and their completions.

2 Likes

I think Google Cloud Functions is awesome in terms of ease of use, flexibility and cost for this sort of thing, particularly if you need large memory or whatnot. Also for many bubble apps you’d never or rarely incur any costs.

Netlify Functions is similar (fewer options), but I don’t think there’s any free usage tier there. We use this with a non-Bubble site I work on that is deployed on Netlify so it makes sense to use their FAAS as well.

2 Likes