I had the loading issue before and I’ve made a lot of improvements, i optimized the query issues, and now the only essential ones are made, i also put only the basic elements to load (i’m requesting the other elements that connect to DB later using ajax) to improve the initial load, the loading was indeed improved compared to before (from 15s to 6s-10s) in production and (from 15s to 2s-3s) in development, but as it figures the production still too slow, I’ve implemented all the improvement that I can on my part, i even upgraded to 4GB ram server but the same problem, i don’t have too much load on the server now 'cause i just started, Any idea what’s going on
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.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
You could also examine your server’s resource utilization - CPU, IO, network - during these slow periods. High resource usage could indicate a bottleneck. If your individual services (like your DB, web server, etc.) are all on the same Droplet, splitting them up across multiple Droplets could help.
You may want to consider using monitoring tools or services to get more insight into what your application and server are doing during these slow times. DigitalOcean provides a monitoring service that can help with this.
https://www.digitalocean.com/community/tutorials/how-to-monitor-cpu-use-on-digitalocean-droplets
https://www.digitalocean.com/community/tutorials/how-to-use-top-netstat-du-other-tools-to-monitor-server-resources
Hope that this helps!
Heya,
While you’ve taken a number of good steps to optimize, loading times of 6-10 seconds in production are still quite high. Here are some suggestions and areas you can investigate further:
Database:
EXPLAIN
command before your SQL queries to see if they’re optimized.Static and Media Files:
ManifestStaticFilesStorage
to add a version to your static files and avoid cache issues.Web Server and WSGI:
Middleware:
Caching:
Third-Party Services:
Network:
Profiling:
Server Monitoring:
htop
orvmstat
can give you insights into what’s consuming resources on your server.Content Delivery:
DEBUG
mode is set toFalse
in production.CONN_MAX_AGE
parameter in your database settings is set to a reasonable value to reuse database connections.If you’ve tried all of the above and you’re still facing issues, it might be worth it to bring in a Django expert to review your setup
Hi there,
The difference in loading times between development and production environments, especially given that they both connect to the same database, could be caused by several things, but you need to keep in mind that if your production server is located geographically far from your database server (or your users), it could add significant latency. Where as when you connect to the app that is actually running locally on your laptop, there will be no network latency at all.
One thing that you could consider using a CDN for serving static assets to ensure they’re delivered quickly to users regardless of their geographic location.
Besides the network latency there are a few other things that you could check:
Server Configuration:
DEBUG
is set toFalse
in production. Also, use theCONN_MAX_AGE
parameter in your database settings to maintain persistent connections to the database.Middleware and Apps:
Database:
Third-party Services:
Caching:
Server Monitoring:
TLS/SSL Overhead:
Optimize Assets:
If, after trying the above suggestions, you’re still facing issues, consider gradually replicating your production environment (software versions, configurations, etc.) in a local or staging setup. This can help isolate the problem by identifying at which step the performance degradation occurs.
Let me know how it goes!
Best,
Bobby