0

I need to create a web interface for a Python numerical simulation code, and host both (interface and python code). When a user will run a simulation, it could take hours, or even days for the simulation to finish (and of course it has to run many simulations in parallel for multiple users).

So I am wondering what are my options to achieve this.

Use a frontend framework for the interface and a web server for the python code ? Or use a framework like Django (which I never used)

And also where can I host such a code (the Python code), is there any provider like AWS or GCP which have a good option for it ?

Guix
  • 308
  • 2
  • 11

1 Answers1

1

You can use any stack for frontend with any framework for backend in Python (e.g. Flask or FastAPI), Django is a great option too (even without experience, you can quickly create a project)!

But I guess whatever option you choose, the part of "code simulation" that takes a lot of time should work separately. For example, you can use something like Celery to queue the tasks. All in all, the part of simulating should be independent from backend and maybe even written in another language, it should only take tasks and return results. You can even host it on another more powerful machine.

What about hosting, I'm not an expert, but I think it depends on the budget, and maybe country. For hosting backend and frontend I think Heroku is a good option, but I'm not sure is it suitable for hosting simulation related part. You can consider options like Google Cloud, Digital Ocean or maybe you can find cheaper VPS providers.

evermake
  • 30
  • 1
  • 4
  • Thanks for your answer I didn't know about Celery, seems great at first glance. There is just a part that I don't really understand. You said I should run simulation and backend separately and I can even run them on different hosting. So how can I connect them ? Is there a protocol like http to connect a web server and an other machine ? – Guix Jun 10 '22 at 18:34
  • @Guix, in case if you will use Celery, it uses a broker (e.g. Redis), you can run Celery on the same machine as your simulation code and connect the backend to it (to the broker) from another machine. So backend will add tasks to queue and your "simulation" machine will enqueue and execute them. Alternatively (but very similar to the previous option), you can use a common DB. Backend will add tasks to some table (in the same way, just add new records) and your "simulation" machine will enqueue them (remove records from DB). I think there are also another options, but these look good IMHO – evermake Jun 10 '22 at 19:06
  • Ah okay I got it ! Thank you it seems a really good option so I will give it a try – Guix Jun 10 '22 at 19:18