I’m trying to migrate an existing Django web app from AWS (using Apache) to DigitalOcean using nginx.
It’s not an identical comparison, but I’m getting massive differences in TTFB which I can’t account for. For a basic page, I’m getting these stats:
Discovered: 0.010 s Request Start: 0.258 s DNS Lookup: 26 ms Initial Connection: 97 ms SSL Negotiation: 118 ms Time to First Byte: 7159 ms Content Download: 2 ms Bytes In (downloaded): 4.9 KB Uncompressed Size: 31.1 KB Bytes Out (uploaded): 0.5 KB
In comparison to my AWS site which is
Discovered: 0.008 s Request Start: 0.124 s DNS Lookup: 27 ms Initial Connection: 31 ms SSL Negotiation: 50 ms Time to First Byte: 579 ms Content Download: 3 ms Bytes In (downloaded): 6.2 KB Uncompressed Size: 34.2 KB Bytes Out (uploaded): 0.5 KB
I’ve followed the tutorials for:
When that resulted in really slow TTFB I proceeded to
In an attempt to see some of the numbers budge, I moved a lot of asset loading to CDN. It ticked a lot of boxes in https://www.webpagetest.org, but it didn’t alter the TTFB, which is by far the biggest bottleneck.
As you can see a 7s TTFB is absolutely massive! Most users keep mentioning times in the >1s range.
I’m totally stumped for ideas now, so short of nuking my droplet and starting from scratch, I’m not sure what else to try.
Is there something I should double check? I can post some configs if that helps.
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!
Maybe my video tutorial can help you (English subtitles): https://www.youtube.com/watch?v=mNw7EyXtT_k&t=686s
and this tutorial with Ubuntu 18.04: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04
My video is based on a compilation of the most important DO tutorials, including security and configuration. It is possible that my Nginx configuration is better prepared for a real case. Or it may, that a small syntax error is causing this slowness. I guess you’ve replaced HTML5 + PHP with HTML5 + Python. You should observe the browser’s command console (F12) and that there is no error. Have you contacted DO support?
@404namenotfound My guess was that TFFB was heavily affected by using an Amazon hosted database but having everything else hosted at DigitalOcean. I wasn’t prepared to migrate the database to DigitalOcean at the time so I had a mix of the app/sever running on DigitalOcean but the database was on AWS. Because of time constraints, I gave up and basically cloned my exact DigitalOcean ubuntu OS configuration to an AWS EC2 nano instance and everything came right. Perhaps if I went all-in on DigitalOcean I could have avoided a high TTFB too.
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.