How can I optimize my Django app to improve performance?
When load testing my app, the response times start degrading significantly after a moderate number of concurrent users. I need strategies to help it maintain speed as usage increases.
I tried caching template fragments and database queries using Django caching framework. I expected this would reduce the load on the database and speeds up rendering, but I didn't see much improvement in my tests.
I profiled the app using Django debug toolbar and found some views were running inefficient queries. I attempted to refactor the queries and models, but the performance impact was minimal. I'm not sure what else could be optimized.
I added database indexes on the most common query filters and ordering, hoping this would speed up the database operations. However, the speed up was not very significant under load.
I deployed the app to a larger server with more CPUs, RAM and SSD storage hoping the increased resources would allow it to handle more load. But I'm still seeing slowdowns and need to optimize the code itself.
I expected optimizing templates down to single queries and caching would get page speeds to below 500ms but I'm still seeing times over 1 second in my tests.