Hi @Chaitawat
Perhaps the streamlit-profiler
might be of use to help you optimize your code:
Alternatively, if this is a computation intensive task, it may be worth to have the simulation live on an external cloud server and interface with that via API call as you had mentioned. Itโs because the Community Cloud computer resource is provided 1 GB memory (StreamlitCloud Computer Specs).
Please have a look at the following blog by @asehmi for some ideas on accessing a remote API from within a Streamlit app.
Best regards,
Chanin