How can I efficiently perform symbolic and numerical tensor computations in a Python web app using Django and SymPy
I'm building a scientific web tool that allows users to input custom spacetime metrics and compute geometric quantities from general relativity — including Christoffel symbols, Ricci, Einstein, and Weyl tensors.
The backend is built in Python using Django, and I’m using SymPy for symbolic computation. I'm also working on a separate C-based module for ray-tracing visualizations of curved spacetime, which may be called through bindings later.
Right now, the frontend is ready and deployed, but the backend (which handles heavy symbolic calculations) is not hosted yet due to cost constraints. I’d like to understand the best architecture and optimization strategies for when I do host it.
My main challenges:
Performance: SymPy can get slow with complex metrics. Are there any best practices to cache or optimize repeated tensor computations?
Deployment: Would you recommend platforms like Render, Fly.io, or Railway for a Django app with heavier symbolic loads?
Is there a better approach to split symbolic and numerical parts to make them more efficient/scalable?
Any security concerns when exposing symbolic input processing to the public?
This is part of an open project I’ve been working on solo. Here's the frontend version: https://itensor.online Docs: https://itensor-docs.com Backend source: https://github.com/Klaudiusz321/Tensor-backend-calculator
Would appreciate any advice from others who’ve built scientific or symbolic computation tools online.