Forums

Flask send_file vs. AWS S3 upload_fileobj

I am trying to send really small packets of data like a .zip file of about 15kb efficiently to the frontend from my Flask backend, but it takes 1-2 seconds. I tried using the Flask send_file which seemed slow, and then I tried uploading the file to AWS S3 and then retrieving it in the frontend, which is an even slower workflow.

Is this a bottleneck here on PythonAnywhere because of the shared resources? Is there any way I can speed this up?

Is it a static asset or something that you generate with your web app code?

I generate the .zip file in the Python backend. Basically it is a package of .glb files which I batch write into the .zip file. The size of the zip is around 15-20 kb. My goal is to upload that package to S3 from the backend, then pull it from the frontend to create my geometry from the .glb files. This process has to be almost instantaneous.

I am currently using the eu-west-2 region for my S3 bucket. Is that the right one to use for PythonAnywhere to reduce latency?

Our US servers are in us-east-1