My app runs on DO Ubuntu droplet, using django + gunicorn + nginx. What it basically does is when somebody loads the page, it makes a lot of requests to third-party API(which is very fast). It is supposed to make ~300 requests in several seconds(how it works on my local computer), but now I tried it with just 30 request and it already takes 6 seconds. How can I speed it up?
I use requests library. I tried multiprocessing to parallelize the code, but it says that I have only one CPU on DO. Moreover I took a look at stats and found out that it takes only ~0.01 Mbps so it’s not DO restriction.
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!
6 seconds to load a page making 300 requests to a 3rd party service isn’t too bad. If there is any way you can reduce these requests I would recommend it as this isn’t a very scalable and efficient setup.
In the short term, is this an application that would benefit from caching. You can use either a 3rd party service like CloudFlare or create your own proxy with nginx. This should reduce the number of requests your server needs to make.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.