What I’m trying to do:
I am building a front end for a simulation game (inspired by earth4all.life). The simulation model is large. One simulated year takes about a second and there are 120 years, so I am running into the server timeout on my free plan.
What are my options?
Go to a paid plan and run the simulation as a background task.
Can I run this “background task” on another server I control and uplink to it?
Can I run the entire app on another server using the open-source anvil server?
Something I did not think of?
Eventually, i.e. for production, I wanted to use option 3 above. Is the timeout limit part of the anvil server, or only of the anvil server when run on anvil.works?
Any guidance is much appreciated.
Thanks, Ulrich
All of these are viable. We use option 2, queueing up our “simulation” jobs, reserving a distinct database table row to receive each result as it is computed.
Our compute engine is written in C++ for speed.
Option 4 might be to create a model engine in a faster (compiled?) language, wrap it in a Python package, and install that package in your server-side runtime environment. This isn’t always practical, though.
Edit: Numpy might be able to accelerate some kinds of calculations.
Would it be possible to restructure your code such that, instead of a single background task that performs simulations for all 120 years, you have a sequence of background tasks, each of which performs simulations for a smaller subset of years?
Thanks for your ideas - chopping up the 120 years into smaller bits is probably the way to go, especially since all results are updated and available in a numpy matrix.