I am facing a bit of a conundrum with how I can structure my application, as I try to balance speed, cost, and efficiency.
I currently have a website, algfinder.com
, which solves states of rubik's cubes. The computation runs purely on the client, and can sometimes crash on mobile devices due to too large of memory demand, as the algorithm to solve the cube takes up a lot of memory.
I would therefore like to implement a backend to do the heavy computation, but have a few notes and concerns.
Notes:
- If I preprocess data, my computations will become very fast. For instance, the average query make take 20 seconds to calculate now, but with 20 GB of preprocessed data, may take < 1 second on average.
- I would like to limit server payments to as little as possible.
The options I see:
- I keep the code as is, have the client do computation, and artificially cap the size of a query a user can make. This is free and easy, but also makes the app slower and less useful.
- I load a very large amount of preprocessed data (20GB+) in an s3, which is cheap. The problem is I will need to make hundreds of thousands of requests to the data, and even at low
GET
requests rates, this will become expensive. - I load a medium amount of preprocessed data into my backend server ram (<5GB), but this is also expensive as I am paying for RAM then, though no db / s3 lookups.
- Have artificial constraints on the app, and provide the user the option to download preprocessed data (~1GB) to their machine to speed up computation.
Does anyone know of a better way to approach this problem? I am a completely new self-taught developer and this is the first project I have ever made so I am a little lost on how I can approach this.
Also, I kindly ask to avoid suggesting to make the algorithm faster or more efficient, it is already decently optimized for the specific use case I am targeting.
Thanks.