I am a Python developer, hosting a Flask application on a DO droplet. I am new to cloud hosting so I am learning as I go and have a question / looking for direction.
I have a simple python script that runs some calculations, and updates an SQLite database. Locally on my macbook it takes ~23 seconds. Running it on my DO droplet, it takes ~222 seconds.
I recently migrated my code to a new DO droplet, I don’t remember the previous droplet being this slow.
This droplet is I believe a shared CPU, Regular 80 gb SSD hdd, 4 gb ram, 2 cpus. It’s running Ubuntu 22.04 and Python 3.10.
I can’t find what the previous droplet was, but it was created when the cheapest option was $5/month for 1 gb / 1 CPU.
What is likely causing this script to be this much slower on my droplet? I know the CPU is not running at 100%.
What can I do to speed it up, at least to the same speed as my desktop? I don’t want to start blindly resizing my droplet.
Thank you
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello @rbourne
I would assume that the part of the script which is taking more time now to complete will be the SQLite database query. Are you doing a remote query or is the database hosted locally on the droplet?
I’ll personally have a look at executing the query via the command line to check if this is the bit that takes more time to complete and then check if the process can be optimized.
Regards
Hi @rbourne,
The script will be slower only if your Droplet is under heavy load when running it or if it’s creating a heavy load. You mentioned the CPU was not at 100% but what about the RAM?
Additionally, try to debug your script. Try to find out on which line it’s slowing down, which command it’s trying to execute for so long, and then take it from there. That would be my approach.